~ubuntu-branches/ubuntu/gutsy/samba/gutsy-updates

« back to all changes in this revision

Viewing changes to source/rpc_parse/parse_misc.c

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Mitchell
  • Date: 2006-11-28 20:14:37 UTC
  • mfrom: (0.10.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061128201437-a6x4lzlhempazocp
Tags: 3.0.23d-1ubuntu1
* Merge from debian unstable.
* Drop python2.4-samba, replace with python-samba. Added Conflicts/Replaces
  on python2.4-samba
* Drop track-connection-dos.patch, ubuntu-winbind-panic.patch, 
  ubuntu-fix-ldap.patch, ubuntu-setlocale.patch, ubuntu-setlocale-fixes.patch
* Remaining Ubuntu changes:
  - Revert Debian's installation of mount.cifs and umount.cifs as suid
  - Comment out the default [homes] shares and add more verbose comments to
    explain what they do and how they work (closes: launchpad.net/27608)
  - Add a "valid users = %S" stanza to the commented-out [homes] section, to
    show users how to restrict access to \\server\username to only username.
  - Change the (commented-out) "printer admin" example to use "@lpadmin"
    instead of "@ntadmin", since the lpadmin group is used for spool admin.
  - Alter the panic-action script to encourage users to report their
    bugs in Ubuntu packages to Ubuntu, rather than reporting to Debian.
    Modify text to more closely match the Debian script
  - Munge our init script to deal with the fact that our implementation
    (or lack thereof) of log_daemon_msg and log_progress_msg differs
    from Debian's implementation of the same (Ubuntu #19691)
  - Kept ubuntu-auxsrc.patch: some auxilliary sources (undocumented in 
    previous changelogs)
  - Set default workgroup to MSHOME

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
free up temporary memory - called from the main loop
50
50
********************************************************************/
51
51
 
52
 
void main_loop_talloc_free(void)
 
52
void main_loop_TALLOC_FREE(void)
53
53
{
54
54
    if (!main_loop_talloc)
55
55
        return;
227
227
}
228
228
 
229
229
/*******************************************************************
230
 
 Inits a DOM_SID structure.
231
 
 
232
 
 BIG NOTE: this function only does SIDS where the identauth is not >= 2^32 
233
 
 identauth >= 2^32 can be detected because it will be specified in hex
234
 
********************************************************************/
235
 
 
236
 
void init_dom_sid(DOM_SID *sid, const char *str_sid)
237
 
{
238
 
        pstring domsid;
239
 
        int identauth;
240
 
        char *p;
241
 
 
242
 
        if (str_sid == NULL) {
243
 
                DEBUG(4,("netlogon domain SID: none\n"));
244
 
                sid->sid_rev_num = 0;
245
 
                sid->num_auths = 0;
246
 
                return;
247
 
        }
248
 
                
249
 
        pstrcpy(domsid, str_sid);
250
 
 
251
 
        DEBUG(4,("init_dom_sid %d SID:  %s\n", __LINE__, domsid));
252
 
 
253
 
        /* assume, but should check, that domsid starts "S-" */
254
 
        p = strtok(domsid+2,"-");
255
 
        sid->sid_rev_num = atoi(p);
256
 
 
257
 
        /* identauth in decimal should be <  2^32 */
258
 
        /* identauth in hex     should be >= 2^32 */
259
 
        identauth = atoi(strtok(0,"-"));
260
 
 
261
 
        DEBUG(4,("netlogon rev %d\n", sid->sid_rev_num));
262
 
        DEBUG(4,("netlogon %s ia %d\n", p, identauth));
263
 
 
264
 
        sid->id_auth[0] = 0;
265
 
        sid->id_auth[1] = 0;
266
 
        sid->id_auth[2] = (identauth & 0xff000000) >> 24;
267
 
        sid->id_auth[3] = (identauth & 0x00ff0000) >> 16;
268
 
        sid->id_auth[4] = (identauth & 0x0000ff00) >> 8;
269
 
        sid->id_auth[5] = (identauth & 0x000000ff);
270
 
 
271
 
        sid->num_auths = 0;
272
 
 
273
 
        while ((p = strtok(0, "-")) != NULL && sid->num_auths < MAXSUBAUTHS)
274
 
                sid->sub_auths[sid->num_auths++] = atoi(p);
275
 
 
276
 
        DEBUG(4,("init_dom_sid: %d SID:  %s\n", __LINE__, domsid));
277
 
}
278
 
 
279
 
/*******************************************************************
280
230
 Inits a DOM_SID2 structure.
281
231
********************************************************************/
282
232
 
597
547
 
598
548
        /* set up string lengths. */
599
549
        str->buf_len = create_rpc_blob(str, len*2);
600
 
        rpcstr_push(str->buffer, buf, str->buf_len, STR_TERMINATE);
 
550
        rpcstr_push(str->buffer, buf, (size_t)str->buf_len, STR_TERMINATE);
601
551
        
602
552
}
603
553
 
762
712
        /* set up string lengths. */
763
713
        SMB_ASSERT(max_len >= str_len);
764
714
 
 
715
        /* Ensure buf is valid if str_len was set. Coverity check. */
 
716
        if (str_len && !buf) {
 
717
                return;
 
718
        }
 
719
 
765
720
        str->str_max_len = max_len;
766
721
        str->offset = 0;
767
722
        str->str_str_len = str_len;
879
834
void init_unistr4(UNISTR4 *uni4, const char *buf, enum unistr2_term_codes flags)
880
835
{
881
836
        uni4->string = TALLOC_P( get_talloc_ctx(), UNISTR2 );
 
837
        if (!uni4->string) {
 
838
                smb_panic("init_unistr4: talloc fail\n");
 
839
                return;
 
840
        }
882
841
        init_unistr2( uni4->string, buf, flags );
883
842
 
884
843
        uni4->length = 2 * (uni4->string->uni_str_len);
888
847
void init_unistr4_w( TALLOC_CTX *ctx, UNISTR4 *uni4, const smb_ucs2_t *buf )
889
848
{
890
849
        uni4->string = TALLOC_P( ctx, UNISTR2 );
 
850
        if (!uni4->string) {
 
851
                smb_panic("init_unistr4_w: talloc fail\n");
 
852
                return;
 
853
        }
891
854
        init_unistr2_w( ctx, uni4->string, buf );
892
855
 
893
856
        uni4->length = 2 * (uni4->string->uni_str_len);
903
866
 
904
867
void init_unistr2_w(TALLOC_CTX *ctx, UNISTR2 *str, const smb_ucs2_t *buf)
905
868
{
906
 
        uint32 len = strlen_w(buf);
 
869
        uint32 len = buf ? strlen_w(buf) : 0;
907
870
 
908
871
        ZERO_STRUCTP(str);
909
872
 
914
877
 
915
878
        str->buffer = TALLOC_ZERO_ARRAY(ctx, uint16, len + 1);
916
879
        if (str->buffer == NULL) {
917
 
                smb_panic("init_unistr2_w: malloc fail\n");
 
880
                smb_panic("init_unistr2_w: talloc fail\n");
918
881
                return;
919
882
        }
920
883
        
1094
1057
 
1095
1058
BOOL prs_unistr4(const char *desc, prs_struct *ps, int depth, UNISTR4 *uni4)
1096
1059
{
 
1060
        void *ptr;
1097
1061
        prs_debug(ps, depth, desc, "prs_unistr4");
1098
1062
        depth++;
1099
1063
 
1102
1066
        if ( !prs_uint16("size", ps, depth, &uni4->size ))
1103
1067
                return False;
1104
1068
                
1105
 
        if ( !prs_pointer( desc, ps, depth, (void**)&uni4->string, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2 ) )
 
1069
        ptr = uni4->string;
 
1070
 
 
1071
        if ( !prs_pointer( desc, ps, depth, &ptr, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2 ) )
1106
1072
                return False;
1107
 
                
 
1073
 
 
1074
        uni4->string = (UNISTR2 *)ptr;
 
1075
        
1108
1076
        return True;
1109
1077
}
1110
1078
 
1251
1219
}
1252
1220
 
1253
1221
/*******************************************************************
1254
 
 Inits a DOM_RID2 structure.
1255
 
********************************************************************/
1256
 
 
1257
 
void init_dom_rid2(DOM_RID2 *rid2, uint32 rid, uint8 type, uint32 idx)
1258
 
{
1259
 
        rid2->type    = type;
1260
 
        rid2->rid     = rid;
1261
 
        rid2->rid_idx = idx;
 
1222
 Inits a DOM_RID structure.
 
1223
********************************************************************/
 
1224
 
 
1225
void init_dom_rid(DOM_RID *prid, uint32 rid, uint16 type, uint32 idx)
 
1226
{
 
1227
        prid->type    = type;
 
1228
        prid->rid     = rid;
 
1229
        prid->rid_idx = idx;
 
1230
}
 
1231
 
 
1232
/*******************************************************************
 
1233
 Reads or writes a DOM_RID structure.
 
1234
********************************************************************/
 
1235
 
 
1236
BOOL smb_io_dom_rid(const char *desc, DOM_RID *rid, prs_struct *ps, int depth)
 
1237
{
 
1238
        if (rid == NULL)
 
1239
                return False;
 
1240
 
 
1241
        prs_debug(ps, depth, desc, "smb_io_dom_rid");
 
1242
        depth++;
 
1243
 
 
1244
        if(!prs_align(ps))
 
1245
                return False;
 
1246
   
 
1247
        if(!prs_uint16("type   ", ps, depth, &rid->type))
 
1248
                return False;
 
1249
        if(!prs_align(ps))
 
1250
                return False;
 
1251
        if(!prs_uint32("rid    ", ps, depth, &rid->rid))
 
1252
                return False;
 
1253
        if(!prs_uint32("rid_idx", ps, depth, &rid->rid_idx))
 
1254
                return False;
 
1255
 
 
1256
        return True;
1262
1257
}
1263
1258
 
1264
1259
/*******************************************************************
1265
1260
 Reads or writes a DOM_RID2 structure.
1266
1261
********************************************************************/
1267
1262
 
1268
 
BOOL smb_io_dom_rid2(const char *desc, DOM_RID2 *rid2, prs_struct *ps, int depth)
 
1263
BOOL smb_io_dom_rid2(const char *desc, DOM_RID2 *rid, prs_struct *ps, int depth)
1269
1264
{
1270
 
        if (rid2 == NULL)
 
1265
        if (rid == NULL)
1271
1266
                return False;
1272
1267
 
1273
1268
        prs_debug(ps, depth, desc, "smb_io_dom_rid2");
1276
1271
        if(!prs_align(ps))
1277
1272
                return False;
1278
1273
   
1279
 
        if(!prs_uint8("type   ", ps, depth, &rid2->type))
 
1274
        if(!prs_uint16("type   ", ps, depth, &rid->type))
1280
1275
                return False;
1281
1276
        if(!prs_align(ps))
1282
1277
                return False;
1283
 
        if(!prs_uint32("rid    ", ps, depth, &rid2->rid))
1284
 
                return False;
1285
 
        if(!prs_uint32("rid_idx", ps, depth, &rid2->rid_idx))
 
1278
        if(!prs_uint32("rid    ", ps, depth, &rid->rid))
 
1279
                return False;
 
1280
        if(!prs_uint32("rid_idx", ps, depth, &rid->rid_idx))
 
1281
                return False;
 
1282
        if(!prs_uint32("unknown", ps, depth, &rid->unknown))
1286
1283
                return False;
1287
1284
 
1288
1285
        return True;
1289
1286
}
1290
1287
 
 
1288
 
1291
1289
/*******************************************************************
1292
1290
creates a DOM_RID3 structure.
1293
1291
********************************************************************/
1368
1366
 Inits or writes a DOM_CLNT_SRV structure.
1369
1367
********************************************************************/
1370
1368
 
1371
 
static BOOL smb_io_clnt_srv(const char *desc, DOM_CLNT_SRV *logcln, prs_struct *ps, int depth)
 
1369
BOOL smb_io_clnt_srv(const char *desc, DOM_CLNT_SRV *logcln, prs_struct *ps, int depth)
1372
1370
{
1373
1371
        if (logcln == NULL)
1374
1372
                return False;