mirror of
https://github.com/samba-team/samba.git
synced 2025-03-24 10:50:22 +03:00
[GLUE] Rsync SAMBA_3_2_0 SVN r25598 in order to create the v3-2-test branch.
(This used to be commit 5c6c8e1fe93f340005110a7833946191659d88ab)
This commit is contained in:
parent
57482469b3
commit
e5a951325a
29
.bzrignore
29
.bzrignore
@ -1,29 +0,0 @@
|
||||
*.o
|
||||
*.po
|
||||
source/client/client_proto.h
|
||||
source/groupdb/mapping.po
|
||||
source/include/build_env.h
|
||||
source/include/config.h
|
||||
source/include/config.h.in
|
||||
source/include/proto.h
|
||||
source/include/stamp-h
|
||||
source/include/version.h
|
||||
source/Makefile
|
||||
source/config.log
|
||||
source/config.status
|
||||
source/configure
|
||||
source/dynconfig.po
|
||||
source/smbadduser
|
||||
source/bin/*
|
||||
source/script/findsmb
|
||||
source/script/gen-8bit-gap.sh
|
||||
source/script/installbin.sh
|
||||
source/script/uninstallbin.sh
|
||||
source/smbd/build_options.c
|
||||
source/utils/net_proto.h
|
||||
source/utils/ntlm_auth_proto.h
|
||||
source/web/swat_proto.h
|
||||
source/nsswitch/winbindd_proto.h
|
||||
source/tags
|
||||
source/utils/passwd_proto.h
|
||||
source/include/includes.h.gch
|
@ -1,6 +1,5 @@
|
||||
WHATS NEW IN Samba 3 SVN
|
||||
========================
|
||||
|
||||
This file is NOT maintained but will be created during releases.
|
||||
See the SAMBA_3_2_RELEASE branch for the current WHATSNEW.
|
||||
==============================
|
||||
Release Notes for Samba 3.2.x
|
||||
XX ##, 200Y
|
||||
==============================
|
||||
|
||||
|
@ -1,11 +0,0 @@
|
||||
ATTENTION
|
||||
DOCS TREE REMOVED
|
||||
---------------------------------------------------
|
||||
|
||||
This docs tree has been moved to a separate SVN
|
||||
module on svn.samba.org named 'samba-docs'.
|
||||
See http://svn.samba.org/samba/subversion.html
|
||||
for details on accessing Samba svn trees.
|
||||
|
||||
For anonymous access to samba-docs, point svn here:
|
||||
svn://svnanon.samba.org/samba-docs/trunk
|
@ -1,22 +0,0 @@
|
||||
CC=gcc
|
||||
INCLUDES= -I`pwd` -I../../../source/ -I../../../source/include -I../../../source/ubiqx
|
||||
|
||||
DEFS= -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
|
||||
|
||||
CFLAGS= -g -Wall -ansi $(INCLUDES)
|
||||
|
||||
OBJ= util.o mgr_group.o mgr_user.o
|
||||
|
||||
LDFLAGS=-L. -L../../bin/
|
||||
LIBS=../../../source/bin/libmsrpc.so
|
||||
|
||||
all: cacusermgr
|
||||
|
||||
cacusermgr: cacusermgr.o $(OBJ)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(OBJ) $(LIBS)
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
rm -f *.o cacusermgr
|
@ -1,343 +0,0 @@
|
||||
/*
|
||||
* Unix SMB/CIFS implementation.
|
||||
* cacusermgr main implementation.
|
||||
*
|
||||
* Copyright (C) Chris Nicholls 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 <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "cacusermgr.h"
|
||||
|
||||
#define DEFAULT_MENU_LINES 15
|
||||
|
||||
|
||||
void create_menu(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *dom_hnd) {
|
||||
struct SamCreateUser cu;
|
||||
struct SamCreateGroup cg;
|
||||
|
||||
fstring in;
|
||||
fstring tmp;
|
||||
|
||||
if(!hnd || !mem_ctx || !dom_hnd) {
|
||||
printf("No Handle to SAM.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/*the menu*/
|
||||
in[0] = '\0';
|
||||
while(in[0] != 'c' && in[0] != 'C' && in[0] != 'q' && in[0] != 'Q') {
|
||||
printf("\n");
|
||||
printf("[u] Create User\n");
|
||||
printf("[g] Create Group\n");
|
||||
printf("[m] Create Machine Account\n");
|
||||
printf("[c] Cancel\n\n");
|
||||
|
||||
printf("Command: ");
|
||||
mgr_getline(in);
|
||||
|
||||
printf("\n");
|
||||
|
||||
switch(in[0]) {
|
||||
case 'u': /*create user*/
|
||||
case 'U':
|
||||
ZERO_STRUCT(cu);
|
||||
cu.in.dom_hnd = dom_hnd;
|
||||
cu.in.acb_mask = ACB_NORMAL;
|
||||
|
||||
printf("Enter name: ");
|
||||
mgr_getline(tmp);
|
||||
cu.in.name = talloc_strdup(mem_ctx, tmp);
|
||||
|
||||
if(!cac_SamCreateUser(hnd, mem_ctx, &cu)) {
|
||||
printerr("Could not create user.", hnd->status);
|
||||
}
|
||||
else {
|
||||
user_menu(hnd, mem_ctx, dom_hnd, cu.out.user_hnd);
|
||||
}
|
||||
|
||||
/*this will break the loop and send us back to the main menu*/
|
||||
in[0] = 'c';
|
||||
break;
|
||||
|
||||
case 'g': /*create group*/
|
||||
case 'G':
|
||||
ZERO_STRUCT(cg);
|
||||
cg.in.dom_hnd = dom_hnd;
|
||||
cg.in.access = MAXIMUM_ALLOWED_ACCESS;
|
||||
|
||||
printf("Enter name: ");
|
||||
mgr_getline(tmp);
|
||||
cg.in.name = talloc_strdup(mem_ctx, tmp);
|
||||
|
||||
if(!cac_SamCreateGroup(hnd, mem_ctx, &cg)) {
|
||||
printerr("Could not create group.", hnd->status);
|
||||
}
|
||||
else {
|
||||
group_menu(hnd, mem_ctx, dom_hnd, cg.out.group_hnd);
|
||||
}
|
||||
|
||||
/*this will break the loop and send us back to the main menu*/
|
||||
in[0] = 'c';
|
||||
break;
|
||||
|
||||
case 'm': /*create machine account*/
|
||||
case 'M':
|
||||
ZERO_STRUCT(cu);
|
||||
cu.in.dom_hnd = dom_hnd;
|
||||
cu.in.acb_mask = ACB_WSTRUST;
|
||||
|
||||
printf("Enter machine name: ");
|
||||
mgr_getline(tmp);
|
||||
|
||||
/*make sure we have a $ on the end*/
|
||||
if(tmp[strlen(tmp) - 1] != '$')
|
||||
cu.in.name = talloc_asprintf(mem_ctx, "%s$", tmp);
|
||||
else
|
||||
cu.in.name = talloc_strdup(mem_ctx, tmp);
|
||||
|
||||
strlower_m(cu.in.name);
|
||||
|
||||
printf("Creating account: %s\n", cu.in.name);
|
||||
|
||||
if(!cac_SamCreateUser(hnd, mem_ctx, &cu)) {
|
||||
printerr("Could not create account.", hnd->status);
|
||||
}
|
||||
else {
|
||||
user_menu(hnd, mem_ctx, dom_hnd, cu.out.user_hnd);
|
||||
}
|
||||
|
||||
/*this will break the loop and send us back to the main menu*/
|
||||
in[0] = 'c';
|
||||
break;
|
||||
|
||||
case 'c': /*cancel*/
|
||||
case 'C':
|
||||
case 'q':
|
||||
case 'Q':
|
||||
/*do nothing*/
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Invalid option\n");
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void main_menu(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *dom_hnd) {
|
||||
fstring in;
|
||||
|
||||
uint32 rid_type = 0;
|
||||
|
||||
struct SamOpenUser openu;
|
||||
struct SamOpenGroup openg;
|
||||
struct SamEnumUsers enumu;
|
||||
struct SamEnumGroups enumg;
|
||||
struct SamFlush flush;
|
||||
|
||||
char *name = NULL;
|
||||
uint32 rid = 0;
|
||||
|
||||
if(!hnd || !mem_ctx || !dom_hnd) {
|
||||
printf("No handle to SAM.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/*initialize this here and don't worry about it later*/
|
||||
ZERO_STRUCT(flush);
|
||||
flush.in.dom_hnd = dom_hnd;
|
||||
|
||||
in[0] = '\0';
|
||||
|
||||
/*handle the menu and commands*/
|
||||
while(in[0] != 'q' && in[0] != 'Q') {
|
||||
printf("\n");
|
||||
|
||||
printf("[o] Open User or Group\n");
|
||||
printf("[c] Create Account or Group\n");
|
||||
printf("[u] List Users\n");
|
||||
printf("[g] List Groups\n");
|
||||
printf("[m] List Machine Accounts\n");
|
||||
printf("[q] Quit\n\n");
|
||||
|
||||
printf("Command: ");
|
||||
|
||||
mgr_getline(in);
|
||||
|
||||
printf("\n");
|
||||
|
||||
switch(in[0]) {
|
||||
case 'o': /*open user or group*/
|
||||
case 'O':
|
||||
printf("Enter RID or Name: ");
|
||||
rid_type = rid_or_name(hnd, mem_ctx, dom_hnd, &rid, &name);
|
||||
|
||||
if(rid_type == CAC_USER_RID) {
|
||||
ZERO_STRUCT(openu);
|
||||
openu.in.dom_hnd = dom_hnd;
|
||||
openu.in.rid = rid;
|
||||
openu.in.access = MAXIMUM_ALLOWED_ACCESS;
|
||||
|
||||
if(!cac_SamOpenUser(hnd, mem_ctx, &openu))
|
||||
printerr("Could not open user.", hnd->status);
|
||||
else {
|
||||
user_menu(hnd, mem_ctx, dom_hnd, openu.out.user_hnd);
|
||||
|
||||
if(!cac_SamFlush(hnd, mem_ctx, &flush)) {
|
||||
printerr("Lost handle while flushing SAM.", hnd->status);
|
||||
/*we want to quit*/
|
||||
in[0] = 'q';
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(rid_type == CAC_GROUP_RID) {
|
||||
ZERO_STRUCT(openg);
|
||||
openg.in.dom_hnd = dom_hnd;
|
||||
openg.in.rid = rid;
|
||||
openg.in.access = MAXIMUM_ALLOWED_ACCESS;
|
||||
|
||||
if(!cac_SamOpenGroup(hnd, mem_ctx, &openg))
|
||||
printerr("Could not open group.", hnd->status);
|
||||
else {
|
||||
group_menu(hnd, mem_ctx, dom_hnd, openg.out.group_hnd);
|
||||
|
||||
if(!cac_SamFlush(hnd, mem_ctx, &flush)) {
|
||||
printerr("Lost handle while flushing SAM.", hnd->status);
|
||||
/*we want to quit*/
|
||||
in[0] = 'q';
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("Unknown RID/Name.\n");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'c': /*create account/group*/
|
||||
case 'C':
|
||||
create_menu(hnd, mem_ctx, dom_hnd);
|
||||
if(!cac_SamFlush(hnd, mem_ctx, &flush)) {
|
||||
printerr("Lost handle while flushing SAM.", hnd->status);
|
||||
/*we want to quit*/
|
||||
in[0] = 'q';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'u': /*list users*/
|
||||
case 'U':
|
||||
ZERO_STRUCT(enumu);
|
||||
enumu.in.dom_hnd = dom_hnd;
|
||||
enumu.in.acb_mask = ACB_NORMAL;
|
||||
|
||||
printf("Users:\n");
|
||||
while(cac_SamEnumUsers(hnd, mem_ctx, &enumu)) {
|
||||
print_rid_list(enumu.out.rids, enumu.out.names, enumu.out.num_users);
|
||||
}
|
||||
if(CAC_OP_FAILED(hnd->status))
|
||||
printerr("Error occured while enumerating users.", hnd->status);
|
||||
break;
|
||||
|
||||
case 'g': /*list groups*/
|
||||
case 'G':
|
||||
ZERO_STRUCT(enumg);
|
||||
enumg.in.dom_hnd = dom_hnd;
|
||||
|
||||
while(cac_SamEnumGroups(hnd, mem_ctx, &enumg)) {
|
||||
print_rid_list( enumg.out.rids, enumg.out.names, enumg.out.num_groups);
|
||||
}
|
||||
|
||||
if(CAC_OP_FAILED(hnd->status))
|
||||
printerr("Error occured while enumerating groups.", hnd->status);
|
||||
break;
|
||||
|
||||
case 'm': /*list machine accounts*/
|
||||
case 'M':
|
||||
ZERO_STRUCT(enumu);
|
||||
enumu.in.dom_hnd = dom_hnd;
|
||||
enumu.in.acb_mask = ACB_WSTRUST;
|
||||
|
||||
printf("Users:\n");
|
||||
while(cac_SamEnumUsers(hnd, mem_ctx, &enumu)) {
|
||||
print_rid_list( enumu.out.rids, enumu.out.names, enumu.out.num_users);
|
||||
}
|
||||
if(CAC_OP_FAILED(hnd->status))
|
||||
printerr("Error occured while enumerating accounts.", hnd->status);
|
||||
break;
|
||||
|
||||
case 'q': /*quit*/
|
||||
case 'Q':
|
||||
/*just do nothing*/
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Invalid Command.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
struct SamOpenDomain sod;
|
||||
|
||||
mem_ctx = talloc_init("cacusermgr");
|
||||
if(!mem_ctx) {
|
||||
printf("Could not initialize Talloc Context\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/**first initialize the server handle with what we have*/
|
||||
hnd = cac_NewServerHandle(True);
|
||||
if(!hnd) {
|
||||
printf("Could not create server handle\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/*fill in the blanks*/
|
||||
if(!process_cmd_line(hnd, mem_ctx, argc, argv))
|
||||
usage();
|
||||
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
printf("Could not connect to server %s. %s\n", hnd->server, nt_errstr(hnd->status));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/*open the domain sam*/
|
||||
ZERO_STRUCT(sod);
|
||||
sod.in.access = MAXIMUM_ALLOWED_ACCESS;
|
||||
|
||||
if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) {
|
||||
printf("Could not open handle to domain SAM. %s\n", nt_errstr(hnd->status));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
main_menu(hnd, mem_ctx, sod.out.dom_hnd);
|
||||
|
||||
cleanup:
|
||||
|
||||
if(sod.out.dom_hnd)
|
||||
cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd);
|
||||
|
||||
if(sod.out.sam)
|
||||
cac_SamClose(hnd, mem_ctx, sod.out.sam);
|
||||
|
||||
cac_FreeHandle(hnd);
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Unix SMB/CIFS implementation.
|
||||
* cacusermgr definitions and includes.
|
||||
*
|
||||
* Copyright (C) Chris Nicholls 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 <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef CACUSERMGR_H_
|
||||
#define CACUSERMGR_H_
|
||||
|
||||
#include "libmsrpc.h"
|
||||
#include "includes.h"
|
||||
|
||||
/*used for the simple pager - mgr_page()*/
|
||||
#define DEFAULT_SCREEN_LINES 20
|
||||
|
||||
/**************
|
||||
* prototypes *
|
||||
**************/
|
||||
|
||||
/*util.c*/
|
||||
void usage();
|
||||
int process_cmd_line(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, int argc, char **argv);
|
||||
void mgr_getline(fstring line);
|
||||
void mgr_page(uint32 line_count);
|
||||
uint32 rid_or_name(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *dom_hnd, uint32 *rid, char **name);
|
||||
char *get_new_password(TALLOC_CTX *mem_ctx);
|
||||
void printerr(const char *msg, NTSTATUS status);
|
||||
void print_rid_list(uint32 *rids, char **names, uint32 num_rids);
|
||||
void print_lookup_records(CacLookupRidsRecord *map, uint32 num_rids);
|
||||
int list_groups(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *dom_hnd);
|
||||
void list_privs(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, CacUserInfo *info);
|
||||
void add_privs(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, CacUserInfo *info);
|
||||
void list_users(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *dom_hnd);
|
||||
|
||||
void mgr_GetAuthDataFn(const char * pServer,
|
||||
const char * pShare,
|
||||
char * pWorkgroup,
|
||||
int maxLenWorkgroup,
|
||||
char * pUsername,
|
||||
int maxLenUsername,
|
||||
char * pPassword,
|
||||
int maxLenPassword);
|
||||
|
||||
|
||||
/*mgr_group.c*/
|
||||
void group_menu(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *dom_hnd, POLICY_HND *group_hnd);
|
||||
|
||||
/*mgr_user.c*/
|
||||
void user_menu(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *dom_hnd, POLICY_HND *user_hnd);
|
||||
|
||||
#endif /*CACUSERMGR_H_*/
|
@ -1,209 +0,0 @@
|
||||
/*
|
||||
* Unix SMB/CIFS implementation.
|
||||
* cacusermgr group implementation.
|
||||
*
|
||||
* Copyright (C) Chris Nicholls 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 <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "cacusermgr.h"
|
||||
|
||||
CacGroupInfo *get_group_info(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *group_hnd) {
|
||||
struct SamGetGroupInfo getinfo;
|
||||
|
||||
if(!hnd || !mem_ctx ||!group_hnd)
|
||||
return NULL;
|
||||
|
||||
ZERO_STRUCT(getinfo);
|
||||
getinfo.in.group_hnd = group_hnd;
|
||||
|
||||
if(!cac_SamGetGroupInfo(hnd, mem_ctx, &getinfo))
|
||||
printerr("Could not get group info.", hnd->status);
|
||||
|
||||
return getinfo.out.info;
|
||||
}
|
||||
|
||||
void print_group_info(CacGroupInfo *info) {
|
||||
if(!info)
|
||||
return;
|
||||
|
||||
printf(" Group Name : %s\n", info->name);
|
||||
printf(" Description : %s\n", info->description);
|
||||
printf(" Number of Members : %d\n", info->num_members);
|
||||
}
|
||||
|
||||
CacGroupInfo *modify_group_info(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *group_hnd) {
|
||||
struct SamSetGroupInfo setinfo;
|
||||
CacGroupInfo *info = NULL;
|
||||
fstring tmp;
|
||||
|
||||
info = get_group_info(hnd, mem_ctx, group_hnd);
|
||||
|
||||
if(!info)
|
||||
return NULL;
|
||||
|
||||
printf("Description [%s]: ", info->description);
|
||||
mgr_getline(tmp);
|
||||
if(tmp[0] != '\0')
|
||||
info->description = talloc_strdup(mem_ctx, tmp);
|
||||
|
||||
ZERO_STRUCT(setinfo);
|
||||
setinfo.in.group_hnd = group_hnd;
|
||||
setinfo.in.info = info;
|
||||
|
||||
if(!cac_SamSetGroupInfo(hnd, mem_ctx, &setinfo)) {
|
||||
printerr("Could not set info.", hnd->status);
|
||||
info = NULL;
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
void group_menu(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *dom_hnd, POLICY_HND *group_hnd) {
|
||||
CacGroupInfo *info = NULL;
|
||||
int rid_type = 0;
|
||||
|
||||
fstring in;
|
||||
|
||||
char *buf;
|
||||
|
||||
struct SamGetGroupMembers getmem;
|
||||
struct SamGetNamesFromRids getnames;
|
||||
struct SamAddGroupMember add;
|
||||
struct SamRemoveGroupMember del;
|
||||
|
||||
info = get_group_info(hnd, mem_ctx, group_hnd);
|
||||
|
||||
printf("\n");
|
||||
print_group_info(info);
|
||||
|
||||
while(in[0] != 'b' && in[0] != 'B' && in[0] != 'q' && in[0] != 'Q') {
|
||||
printf("\n");
|
||||
printf("[m] List Group Members\n");
|
||||
printf("[a] Add User To Group\n");
|
||||
printf("[r] Remove User From Group\n");
|
||||
printf("[l] List Users\n");
|
||||
printf("[v] View Group Info\n");
|
||||
printf("[d] Set Group Description\n");
|
||||
printf("[x] Delete Group\n");
|
||||
printf("[b] Back\n\n");
|
||||
|
||||
printf("Command: ");
|
||||
mgr_getline(in);
|
||||
|
||||
printf("\n");
|
||||
|
||||
switch(in[0]) {
|
||||
case 'a': /*add member to group*/
|
||||
case 'A':
|
||||
ZERO_STRUCT(add);
|
||||
add.in.group_hnd = group_hnd;
|
||||
|
||||
printf("Enter RID or Name: ");
|
||||
rid_type = rid_or_name(hnd, mem_ctx, dom_hnd, &add.in.rid, &buf);
|
||||
|
||||
if(rid_type != CAC_USER_RID) {
|
||||
printf("Invalid User.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if(!cac_SamAddGroupMember(hnd, mem_ctx, &add)) {
|
||||
printerr("Could not add user to group.", hnd->status);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'r': /*remove user from group*/
|
||||
case 'R':
|
||||
ZERO_STRUCT(del);
|
||||
del.in.group_hnd = group_hnd;
|
||||
|
||||
printf("Enter RID or Name: ");
|
||||
rid_type = rid_or_name(hnd, mem_ctx, dom_hnd, &del.in.rid, &buf);
|
||||
|
||||
if(rid_type != CAC_USER_RID) {
|
||||
printf("Invalid User.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if(!cac_SamRemoveGroupMember(hnd, mem_ctx, &del)) {
|
||||
printerr("Could not remove use from group.", hnd->status);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'l': /*list users*/
|
||||
case 'L':
|
||||
list_users(hnd, mem_ctx, dom_hnd);
|
||||
break;
|
||||
|
||||
case 'm': /*list members*/
|
||||
case 'M':
|
||||
ZERO_STRUCT(getmem);
|
||||
getmem.in.group_hnd = group_hnd;
|
||||
|
||||
if(!cac_SamGetGroupMembers(hnd, mem_ctx, &getmem)) {
|
||||
printerr("Could not get members.", hnd->status);
|
||||
break;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(getnames);
|
||||
getnames.in.dom_hnd = dom_hnd;
|
||||
getnames.in.rids = getmem.out.rids;
|
||||
getnames.in.num_rids = getmem.out.num_members;
|
||||
|
||||
if(!cac_SamGetNamesFromRids(hnd, mem_ctx, &getnames)) {
|
||||
printerr("Could not lookup names.", hnd->status);
|
||||
break;
|
||||
}
|
||||
|
||||
printf("Group has %d members:\n", getnames.out.num_names);
|
||||
print_lookup_records(getnames.out.map, getnames.out.num_names);
|
||||
|
||||
break;
|
||||
|
||||
case 'd': /*set description*/
|
||||
case 'D':
|
||||
info = modify_group_info(hnd, mem_ctx, group_hnd);
|
||||
|
||||
if(info)
|
||||
printf("Set Group Info.\n");
|
||||
break;
|
||||
|
||||
case 'v': /*view info*/
|
||||
case 'V':
|
||||
info = get_group_info(hnd, mem_ctx, group_hnd);
|
||||
print_group_info(info);
|
||||
break;
|
||||
|
||||
case 'x': /*delete group*/
|
||||
case 'X':
|
||||
if(!cac_SamDeleteGroup(hnd, mem_ctx, group_hnd))
|
||||
printerr("Could Not Delete Group.", hnd->status);
|
||||
|
||||
/*we want to go back to the main menu*/
|
||||
in[0] = 'b';
|
||||
break;
|
||||
|
||||
case 'b': /*back*/
|
||||
case 'B':
|
||||
case 'q':
|
||||
case 'Q':
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Invalid Command.\n");
|
||||
}
|
||||
}
|
||||
|
||||
cac_SamClose(hnd, mem_ctx, group_hnd);
|
||||
}
|
@ -1,415 +0,0 @@
|
||||
/*
|
||||
* Unix SMB/CIFS implementation.
|
||||
* cacusermgr user implementation.
|
||||
*
|
||||
* Copyright (C) Chris Nicholls 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 <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "cacusermgr.h"
|
||||
|
||||
void print_user_info(CacUserInfo *info) {
|
||||
printf("\n");
|
||||
printf(" User Name : %s\n", info->username);
|
||||
printf(" Full Name : %s\n", info->full_name);
|
||||
printf(" Home Dir : %s\n", info->home_dir);
|
||||
printf(" Home Drive : %s\n", info->home_drive);
|
||||
printf(" Profile Path : %s\n", info->profile_path);
|
||||
printf(" Logon Script : %s\n", info->logon_script);
|
||||
printf(" Description : %s\n", info->description);
|
||||
printf(" Workstations : %s\n", info->workstations);
|
||||
printf(" Remote Dial : %s\n", info->dial);
|
||||
|
||||
printf(" Logon Time : %s\n", http_timestring(info->logon_time));
|
||||
printf(" Logoff Time : %s\n", http_timestring(info->logoff_time));
|
||||
printf(" Kickoff Time : %s\n", http_timestring(info->kickoff_time));
|
||||
printf(" Pass last set : %s\n", http_timestring(info->pass_last_set_time));
|
||||
printf(" Pass can set : %s\n", http_timestring(info->pass_can_change_time));
|
||||
printf(" Pass must set : %s\n", http_timestring(info->pass_must_change_time));
|
||||
|
||||
printf(" User RID : 0x%x\n", info->rid);
|
||||
printf(" Group RID : 0x%x\n", info->group_rid);
|
||||
printf(" User Type : ");
|
||||
|
||||
if(info->acb_mask & ACB_NORMAL)
|
||||
printf("Normal User\n");
|
||||
else if(info->acb_mask & ACB_TEMPDUP)
|
||||
printf("Temporary Duplicate Account\n");
|
||||
else if(info->acb_mask & ACB_DOMTRUST)
|
||||
printf("Inter-Domain Trust Account\n");
|
||||
else if(info->acb_mask & ACB_WSTRUST)
|
||||
printf("Workstation Trust Account\n");
|
||||
else if(info->acb_mask & ACB_SVRTRUST)
|
||||
printf("Server Trust Account\n");
|
||||
else
|
||||
printf("\n");
|
||||
|
||||
printf(" Disabled : %s\n", (info->acb_mask & ACB_DISABLED) ? "Yes" : "No");
|
||||
printf(" Locked : %s\n", (info->acb_mask & ACB_AUTOLOCK) ? "Yes" : "No");
|
||||
printf(" Pass Expires : %s\n", (info->acb_mask & ACB_PWNOEXP) ? "No" : "Yes");
|
||||
printf(" Pass Required : %s\n", (info->acb_mask & ACB_PWNOTREQ) ? "No" : "Yes");
|
||||
|
||||
}
|
||||
|
||||
CacUserInfo *modify_user_info(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *user_hnd) {
|
||||
CacUserInfo *info = NULL;
|
||||
fstring tmp;
|
||||
|
||||
struct SamGetUserInfo getinfo;
|
||||
struct SamSetUserInfo setinfo;
|
||||
|
||||
ZERO_STRUCT(getinfo);
|
||||
ZERO_STRUCT(setinfo);
|
||||
|
||||
getinfo.in.user_hnd = user_hnd;
|
||||
|
||||
if(!cac_SamGetUserInfo(hnd, mem_ctx, &getinfo)) {
|
||||
printerr("Could not get user info.", hnd->status);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
info = getinfo.out.info;
|
||||
|
||||
printf("\n");
|
||||
printf(" User Name [%s]: ", info->username);
|
||||
mgr_getline(tmp);
|
||||
if(tmp[0] != '\0')
|
||||
info->username = talloc_strdup(mem_ctx, tmp);
|
||||
|
||||
printf(" Full Name [%s]: ", info->full_name);
|
||||
mgr_getline(tmp);
|
||||
if(tmp[0] != '\0')
|
||||
info->full_name = talloc_strdup(mem_ctx, tmp);
|
||||
|
||||
printf(" Description [%s]: ", info->description);
|
||||
mgr_getline(tmp);
|
||||
if(tmp[0] != '\0')
|
||||
info->description = talloc_strdup(mem_ctx, tmp);
|
||||
|
||||
printf(" Home Dir [%s]: ", info->home_dir);
|
||||
mgr_getline(tmp);
|
||||
if(tmp[0] != '\0')
|
||||
info->home_dir = talloc_strdup(mem_ctx, tmp);
|
||||
|
||||
printf(" Home Drive [%s]: ", info->home_drive);
|
||||
mgr_getline(tmp);
|
||||
if(tmp[0] != '\0')
|
||||
info->home_drive = talloc_strdup(mem_ctx, tmp);
|
||||
|
||||
printf(" Profile Path [%s]: ", info->profile_path);
|
||||
mgr_getline(tmp);
|
||||
if(tmp[0] != '\0')
|
||||
info->profile_path = talloc_strdup(mem_ctx, tmp);
|
||||
|
||||
printf(" Logon Script [%s]: ", info->logon_script);
|
||||
mgr_getline(tmp);
|
||||
if(tmp[0] != '\0')
|
||||
info->logon_script = talloc_strdup(mem_ctx, tmp);
|
||||
|
||||
printf(" Workstations [%s]: ", info->workstations);
|
||||
mgr_getline(tmp);
|
||||
if(tmp[0] != '\0')
|
||||
info->workstations = talloc_strdup(mem_ctx, tmp);
|
||||
|
||||
printf(" Remote Dial [%s]: ", info->dial);
|
||||
mgr_getline(tmp);
|
||||
if(tmp[0] != '\0')
|
||||
info->dial = talloc_strdup(mem_ctx, tmp);
|
||||
|
||||
printf(" Disabled [%s] (y/n): ", (info->acb_mask & ACB_DISABLED) ? "Yes" : "No");
|
||||
mgr_getline(tmp);
|
||||
if(tmp[0] == 'y' || tmp[0] == 'Y')
|
||||
info->acb_mask |= ACB_DISABLED;
|
||||
else if(tmp[0] == 'n' || tmp[0] == 'N')
|
||||
info->acb_mask ^= (info->acb_mask & ACB_DISABLED) ? ACB_DISABLED : 0x0;
|
||||
|
||||
printf(" Pass Expires [%s] (y/n): ", (info->acb_mask & ACB_PWNOEXP) ? "No" : "Yes");
|
||||
mgr_getline(tmp);
|
||||
if(tmp[0] == 'n' || tmp[0] == 'N')
|
||||
info->acb_mask |= ACB_PWNOEXP;
|
||||
else if(tmp[0] == 'y' || tmp[0] == 'Y')
|
||||
info->acb_mask ^= (info->acb_mask & ACB_PWNOEXP) ? ACB_PWNOEXP : 0x0;
|
||||
|
||||
printf(" Pass Required [%s] (y/n): ", (info->acb_mask & ACB_PWNOTREQ) ? "No" : "Yes");
|
||||
mgr_getline(tmp);
|
||||
if(tmp[0] == 'n' || tmp[0] == 'N')
|
||||
info->acb_mask |= ACB_PWNOTREQ;
|
||||
else if(tmp[0] == 'y' || tmp[0] == 'Y')
|
||||
info->acb_mask ^= (info->acb_mask & ACB_PWNOTREQ) ? ACB_PWNOTREQ : 0x0;
|
||||
|
||||
setinfo.in.user_hnd = user_hnd;
|
||||
setinfo.in.info = info;
|
||||
|
||||
if(!cac_SamSetUserInfo(hnd, mem_ctx, &setinfo)) {
|
||||
printerr("Could not set user info.", hnd->status);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
void add_user_to_group(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, CacUserInfo *info, POLICY_HND *dom_hnd) {
|
||||
int rid_type = 0;
|
||||
|
||||
char *tmp = NULL;
|
||||
|
||||
struct SamOpenGroup og;
|
||||
struct SamAddGroupMember add;
|
||||
|
||||
ZERO_STRUCT(og);
|
||||
ZERO_STRUCT(add);
|
||||
|
||||
printf("Group RID or Name:");
|
||||
|
||||
og.in.dom_hnd = dom_hnd;
|
||||
og.in.access = MAXIMUM_ALLOWED_ACCESS;
|
||||
rid_type = rid_or_name(hnd, mem_ctx, dom_hnd, &og.in.rid, &tmp);
|
||||
|
||||
if(!cac_SamOpenGroup(hnd, mem_ctx, &og)) {
|
||||
printerr("Could not open group.", hnd->status);
|
||||
return;
|
||||
}
|
||||
|
||||
add.in.group_hnd = og.out.group_hnd;
|
||||
add.in.rid = info->rid;
|
||||
|
||||
if(!cac_SamAddGroupMember(hnd, mem_ctx, &add)) {
|
||||
printerr("Could not add user to group.", hnd->status);
|
||||
}
|
||||
|
||||
cac_SamClose(hnd, mem_ctx, og.out.group_hnd);
|
||||
}
|
||||
|
||||
void remove_user_from_group(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, CacUserInfo *info, POLICY_HND *dom_hnd) {
|
||||
int rid_type = 0;
|
||||
|
||||
char *tmp = NULL;
|
||||
|
||||
struct SamOpenGroup og;
|
||||
struct SamRemoveGroupMember del;
|
||||
|
||||
ZERO_STRUCT(og);
|
||||
ZERO_STRUCT(del);
|
||||
|
||||
printf("Group RID or Name:");
|
||||
|
||||
og.in.dom_hnd = dom_hnd;
|
||||
og.in.access = MAXIMUM_ALLOWED_ACCESS;
|
||||
rid_type = rid_or_name(hnd, mem_ctx, dom_hnd, &og.in.rid, &tmp);
|
||||
|
||||
if(!cac_SamOpenGroup(hnd, mem_ctx, &og)) {
|
||||
printerr("Could not open group.", hnd->status);
|
||||
return;
|
||||
}
|
||||
|
||||
del.in.group_hnd = og.out.group_hnd;
|
||||
del.in.rid = info->rid;
|
||||
|
||||
if(!cac_SamRemoveGroupMember(hnd, mem_ctx, &del)) {
|
||||
printerr("Could not add user to group.", hnd->status);
|
||||
}
|
||||
|
||||
cac_SamClose(hnd, mem_ctx, og.out.group_hnd);
|
||||
}
|
||||
|
||||
void user_menu(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *dom_hnd, POLICY_HND *user_hnd) {
|
||||
fstring in;
|
||||
|
||||
struct SamGetUserInfo getinfo;
|
||||
struct SamSetPassword setpass;
|
||||
struct SamGetGroupsForUser groups;
|
||||
struct SamGetNamesFromRids gnfr;
|
||||
|
||||
CacUserInfo *info = NULL;
|
||||
|
||||
if(!hnd || !mem_ctx || !user_hnd) {
|
||||
printf("Must open user.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/*get the userinfo and print it out*/
|
||||
ZERO_STRUCT(getinfo);
|
||||
getinfo.in.user_hnd = user_hnd;
|
||||
|
||||
if(!cac_SamGetUserInfo(hnd, mem_ctx, &getinfo)) {
|
||||
printerr("Could not get info.", hnd->status);
|
||||
info = NULL;
|
||||
}
|
||||
else {
|
||||
info = getinfo.out.info;
|
||||
print_user_info(info);
|
||||
}
|
||||
|
||||
/*now deal with the menu*/
|
||||
in[0] = '\0';
|
||||
while(in[0] != 'b' && in[0] != 'B' && in[0] != 'q' && in[0] != 'Q') {
|
||||
printf("\n");
|
||||
printf("[s] Set Password\n");
|
||||
|
||||
if(info && (info->acb_mask & ACB_DISABLED))
|
||||
printf("[e] Enable User\n");
|
||||
else if(info)
|
||||
printf("[d] Disable User\n");
|
||||
|
||||
printf("[v] View User Info\n");
|
||||
printf("[m] Modify User Info\n");
|
||||
printf("[x] Delete User\n\n");
|
||||
|
||||
printf("[g] List Group Membership\n");
|
||||
printf("[a] Add User To Group\n");
|
||||
printf("[l] List Domain Groups\n");
|
||||
printf("[r] Remove User From Group\n\n");
|
||||
|
||||
printf("[b] Back\n\n");
|
||||
|
||||
printf("Command: ");
|
||||
mgr_getline(in);
|
||||
|
||||
printf("\n");
|
||||
|
||||
switch(in[0]) {
|
||||
case 'g': /*list group membership*/
|
||||
case 'G':
|
||||
ZERO_STRUCT(groups);
|
||||
groups.in.user_hnd = user_hnd;
|
||||
|
||||
if(!cac_SamGetGroupsForUser(hnd, mem_ctx, &groups)) {
|
||||
printerr("Could not get groups.", hnd->status);
|
||||
break;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(gnfr);
|
||||
gnfr.in.dom_hnd = dom_hnd;
|
||||
gnfr.in.rids = groups.out.rids;
|
||||
gnfr.in.num_rids = groups.out.num_groups;
|
||||
|
||||
if(!cac_SamGetNamesFromRids(hnd, mem_ctx, &gnfr)) {
|
||||
printerr("Could not map RIDs to names.", hnd->status);
|
||||
break;
|
||||
}
|
||||
|
||||
print_lookup_records(gnfr.out.map, gnfr.out.num_names);
|
||||
|
||||
break;
|
||||
case 's': /*reset password*/
|
||||
case 'S':
|
||||
ZERO_STRUCT(setpass);
|
||||
setpass.in.user_hnd = user_hnd;
|
||||
setpass.in.password = get_new_password(mem_ctx);
|
||||
|
||||
if(!setpass.in.password) {
|
||||
printf("Out of memory.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if(!cac_SamSetPassword(hnd, mem_ctx, &setpass)) {
|
||||
printerr("Could not set password.", hnd->status);
|
||||
}
|
||||
else {
|
||||
printf("Reset password.\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case 'e': /*enable user*/
|
||||
case 'E':
|
||||
if(info && !(info->acb_mask & ACB_DISABLED))
|
||||
break;
|
||||
|
||||
if(!cac_SamEnableUser(hnd, mem_ctx, user_hnd)) {
|
||||
printerr("Could not enable user.", hnd->status);
|
||||
}
|
||||
else {
|
||||
printf("Enabled User.\n");
|
||||
/*toggle the disabled ACB bit in our local copy of the info*/
|
||||
info->acb_mask ^= ACB_DISABLED;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'd': /*disable user*/
|
||||
case 'D':
|
||||
if(info && (info->acb_mask & ACB_DISABLED))
|
||||
break;
|
||||
|
||||
if(!cac_SamDisableUser(hnd, mem_ctx, user_hnd)) {
|
||||
printerr("Could not disable user.", hnd->status);
|
||||
}
|
||||
else {
|
||||
printf("Disabled User.\n");
|
||||
/*toggle the disabled ACB bit in our local copy of the info*/
|
||||
info->acb_mask ^= ACB_DISABLED;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'v': /*view user info*/
|
||||
case 'V':
|
||||
ZERO_STRUCT(getinfo);
|
||||
getinfo.in.user_hnd = user_hnd;
|
||||
|
||||
if(!cac_SamGetUserInfo(hnd, mem_ctx, &getinfo)) {
|
||||
printerr("Could not get info.", hnd->status);
|
||||
info = NULL;
|
||||
}
|
||||
else {
|
||||
info = getinfo.out.info;
|
||||
print_user_info(info);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'm': /*modify user info*/
|
||||
case 'M':
|
||||
info = modify_user_info(hnd, mem_ctx, user_hnd);
|
||||
|
||||
if(info)
|
||||
printf("Updated user info.\n");
|
||||
break;
|
||||
|
||||
case 'l': /*list domain groups*/
|
||||
case 'L':
|
||||
list_groups(hnd, mem_ctx, dom_hnd);
|
||||
break;
|
||||
|
||||
case 'a': /*add user to group*/
|
||||
case 'A':
|
||||
add_user_to_group(hnd, mem_ctx, info, dom_hnd);
|
||||
break;
|
||||
|
||||
case 'r': /*remove user from group*/
|
||||
case 'R':
|
||||
remove_user_from_group(hnd, mem_ctx, info, dom_hnd);
|
||||
break;
|
||||
|
||||
case 'x': /*delete user*/
|
||||
case 'X':
|
||||
if(!cac_SamDeleteUser(hnd, mem_ctx, user_hnd))
|
||||
printerr("Could not delete user.", hnd->status);
|
||||
|
||||
/*we want to go back to the main menu*/
|
||||
in[0] = 'b';
|
||||
break;
|
||||
|
||||
case 'b': /*back*/
|
||||
case 'B':
|
||||
case 'q':
|
||||
case 'Q':
|
||||
/*do nothing*/
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Invalid command.\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*close the user before returning*/
|
||||
cac_SamClose(hnd, mem_ctx, user_hnd);
|
||||
}
|
@ -1,342 +0,0 @@
|
||||
/*
|
||||
* Unix SMB/CIFS implementation.
|
||||
* cacusermgr utility functions.
|
||||
*
|
||||
* Copyright (C) Chris Nicholls 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 <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "cacusermgr.h"
|
||||
|
||||
/*prints usage and quits*/
|
||||
void usage() {
|
||||
printf("Usage:\n");
|
||||
printf(" cacusermgr [options] server\n\n");
|
||||
printf("options:\n");
|
||||
printf(" -u USERNAME Username to login with\n");
|
||||
printf(" -d/-w DOMAIN Domain name\n");
|
||||
printf(" -D LEVEL Debug level\n");
|
||||
printf(" -h Print this message\n");
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*initializes values in the server handle from the command line returns 0 if there is a problem, non-zero if everything is ok*/
|
||||
int process_cmd_line(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, int argc, char **argv) {
|
||||
char op;
|
||||
|
||||
if(!hnd || !mem_ctx || !argc)
|
||||
return 0;
|
||||
|
||||
while( (op = getopt(argc, argv, "u:U:d:w:W:D:h")) != -1) {
|
||||
switch(op) {
|
||||
case 'u': /*username*/
|
||||
case 'U':
|
||||
if(optarg)
|
||||
strncpy(hnd->username, optarg, sizeof(fstring));
|
||||
else
|
||||
usage();
|
||||
break;
|
||||
|
||||
case 'd': /*domain name*/
|
||||
case 'w':
|
||||
case 'W':
|
||||
if(optarg)
|
||||
strncpy(hnd->domain, optarg, sizeof(fstring));
|
||||
else
|
||||
usage();
|
||||
break;
|
||||
|
||||
case 'D': /*debug level*/
|
||||
if(optarg)
|
||||
hnd->debug = atoi(optarg);
|
||||
else
|
||||
usage();
|
||||
break;
|
||||
|
||||
case 'h': /*help*/
|
||||
usage();
|
||||
break;
|
||||
|
||||
case '?':
|
||||
default:
|
||||
printf("Unknown option -%c\n", op);
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
if(optind >= argc)
|
||||
usage();
|
||||
|
||||
/*whatever is less should be the server*/
|
||||
strncpy(hnd->server, argv[optind], sizeof(fstring));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void mgr_getline(fstring line) {
|
||||
|
||||
fgets(line, sizeof(fstring), stdin);
|
||||
|
||||
if(line[strlen(line) - 1] == '\n')
|
||||
line[strlen(line) - 1] = '\0';
|
||||
|
||||
}
|
||||
|
||||
/*this is pretty similar to the other get_auth_data_fn's*/
|
||||
void mgr_GetAuthDataFn(const char * pServer,
|
||||
const char * pShare,
|
||||
char * pWorkgroup,
|
||||
int maxLenWorkgroup,
|
||||
char * pUsername,
|
||||
int maxLenUsername,
|
||||
char * pPassword,
|
||||
int maxLenPassword)
|
||||
|
||||
{
|
||||
char temp[sizeof(fstring)];
|
||||
|
||||
static char authUsername[sizeof(fstring)];
|
||||
static char authWorkgroup[sizeof(fstring)];
|
||||
static char authPassword[sizeof(fstring)];
|
||||
static char authSet = 0;
|
||||
|
||||
char *pass = NULL;
|
||||
|
||||
if (authSet)
|
||||
{
|
||||
strncpy(pWorkgroup, authWorkgroup, maxLenWorkgroup - 1);
|
||||
strncpy(pUsername, authUsername, maxLenUsername - 1);
|
||||
strncpy(pPassword, authPassword, maxLenPassword - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(pWorkgroup[0] != '\0') {
|
||||
strncpy(authWorkgroup, pWorkgroup, maxLenWorkgroup - 1);
|
||||
}
|
||||
else {
|
||||
d_printf("Domain: [%s] ", pWorkgroup);
|
||||
mgr_getline(pWorkgroup);
|
||||
|
||||
if (temp[0] != '\0')
|
||||
{
|
||||
strncpy(pWorkgroup, temp, maxLenWorkgroup - 1);
|
||||
strncpy(authWorkgroup, temp, maxLenWorkgroup - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(pUsername[0] != '\0') {
|
||||
strncpy(authUsername, pUsername, maxLenUsername - 1);
|
||||
}
|
||||
else {
|
||||
d_printf("Username: [%s] ", pUsername);
|
||||
mgr_getline(pUsername);
|
||||
|
||||
if (temp[strlen(temp) - 1] == '\n') /* A new line? */
|
||||
{
|
||||
temp[strlen(temp) - 1] = '\0';
|
||||
}
|
||||
|
||||
if (temp[0] != '\0')
|
||||
{
|
||||
strncpy(pUsername, temp, maxLenUsername - 1);
|
||||
strncpy(authUsername, pUsername, maxLenUsername - 1);
|
||||
}
|
||||
}
|
||||
if(pPassword[0] != '\0') {
|
||||
strncpy(authPassword, pPassword, maxLenPassword - 1);
|
||||
}
|
||||
else {
|
||||
pass = getpass("Password: ");
|
||||
if (pass)
|
||||
fstrcpy(temp, pass);
|
||||
if (temp[strlen(temp) - 1] == '\n') /* A new line? */
|
||||
{
|
||||
temp[strlen(temp) - 1] = '\0';
|
||||
}
|
||||
if (temp[0] != '\0')
|
||||
{
|
||||
strncpy(pPassword, temp, maxLenPassword - 1);
|
||||
strncpy(authPassword, pPassword, maxLenPassword - 1);
|
||||
}
|
||||
}
|
||||
authSet = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void mgr_page(uint32 line_count) {
|
||||
|
||||
if( (line_count % DEFAULT_SCREEN_LINES) != 0)
|
||||
return;
|
||||
|
||||
printf("--Press enter to continue--\n");
|
||||
getchar();
|
||||
}
|
||||
|
||||
/*reads a line from stdin, figures out if it is a RID or name, gets a CacLookupRidsRecord and then returns the type*/
|
||||
uint32 rid_or_name(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *dom_hnd, uint32 *rid, char **name) {
|
||||
fstring line;
|
||||
|
||||
BOOL is_rid = False;
|
||||
uint32 rid_type = 0;
|
||||
|
||||
struct SamGetNamesFromRids getnames;
|
||||
struct SamGetRidsFromNames getrids;
|
||||
|
||||
mgr_getline(line);
|
||||
|
||||
if(strncmp(line, "0x", 2) == 0) {
|
||||
/*then this is a RID*/
|
||||
sscanf( (line + 2), "%x", rid);
|
||||
is_rid = True;
|
||||
}
|
||||
else {
|
||||
/*then this is a name*/
|
||||
*name = talloc_strdup(mem_ctx, line);
|
||||
}
|
||||
|
||||
if(is_rid) {
|
||||
ZERO_STRUCT(getnames);
|
||||
|
||||
getnames.in.dom_hnd = dom_hnd;
|
||||
getnames.in.rids = rid;
|
||||
getnames.in.num_rids = 1;
|
||||
|
||||
cac_SamGetNamesFromRids(hnd, mem_ctx, &getnames);
|
||||
|
||||
if(getnames.out.num_names > 0)
|
||||
rid_type = getnames.out.map[0].type;
|
||||
|
||||
}
|
||||
else {
|
||||
ZERO_STRUCT(getrids);
|
||||
|
||||
getrids.in.dom_hnd = dom_hnd;
|
||||
getrids.in.names = name;
|
||||
getrids.in.num_names = 1;
|
||||
|
||||
cac_SamGetRidsFromNames(hnd, mem_ctx, &getrids);
|
||||
|
||||
if(getrids.out.num_rids > 0) {
|
||||
rid_type = getrids.out.map[0].type;
|
||||
|
||||
/*send back the RID so cac_SamOpenXX() doesn't have to look it up*/
|
||||
*rid = getrids.out.map[0].rid;
|
||||
}
|
||||
}
|
||||
|
||||
return rid_type;
|
||||
}
|
||||
|
||||
/*print's out some common error messages*/
|
||||
void printerr(const char *msg, NTSTATUS status) {
|
||||
if(NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED))
|
||||
printf("%s You do not have sufficient rights.\n", msg);
|
||||
|
||||
else if(NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_USER))
|
||||
printf("%s No such user.\n", msg);
|
||||
|
||||
else if(NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_GROUP))
|
||||
printf("%s No such group.\n", msg);
|
||||
|
||||
else if(NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS))
|
||||
printf("%s User already exists.\n", msg);
|
||||
|
||||
else if(NT_STATUS_EQUAL(status, NT_STATUS_GROUP_EXISTS))
|
||||
printf("%s Group already exists.\n", msg);
|
||||
|
||||
else
|
||||
printf("%s %s.\n", msg, nt_errstr(status));
|
||||
}
|
||||
|
||||
char *get_new_password(TALLOC_CTX *mem_ctx) {
|
||||
char *pass1 = NULL;
|
||||
|
||||
pass1 = getpass("Enter new password: ");
|
||||
|
||||
return talloc_strdup(mem_ctx, pass1);
|
||||
}
|
||||
|
||||
void print_rid_list(uint32 *rids, char **names, uint32 num_rids) {
|
||||
uint32 i = 0;
|
||||
|
||||
if(!names || !rids)
|
||||
return;
|
||||
|
||||
printf(" RID Name\n");
|
||||
|
||||
while(i < num_rids) {
|
||||
printf("[0x%x] [%s]\n", rids[i], names[i]);
|
||||
|
||||
i++;
|
||||
|
||||
mgr_page(i);
|
||||
}
|
||||
}
|
||||
|
||||
void print_lookup_records(CacLookupRidsRecord *map, uint32 num_rids) {
|
||||
uint32 i = 0;
|
||||
|
||||
if(!map)
|
||||
return;
|
||||
|
||||
printf("RID Name\n");
|
||||
|
||||
while(i < num_rids) {
|
||||
if(map[i].found) {
|
||||
printf("[0x%x] [%s]\n", map[i].rid, map[i].name);
|
||||
}
|
||||
|
||||
i++;
|
||||
|
||||
mgr_page(i);
|
||||
}
|
||||
}
|
||||
|
||||
int list_groups(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *dom_hnd) {
|
||||
struct SamEnumGroups eg;
|
||||
|
||||
if(!hnd || !mem_ctx || !dom_hnd)
|
||||
return 0;
|
||||
|
||||
ZERO_STRUCT(eg);
|
||||
eg.in.dom_hnd = dom_hnd;
|
||||
|
||||
while(cac_SamEnumGroups(hnd, mem_ctx, &eg))
|
||||
print_rid_list(eg.out.rids, eg.out.names, eg.out.num_groups);
|
||||
|
||||
if(CAC_OP_FAILED(hnd->status)) {
|
||||
printerr("Could not enumerate groups.", hnd->status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void list_users(CacServerHandle *hnd, TALLOC_CTX *mem_ctx, POLICY_HND *dom_hnd) {
|
||||
struct SamEnumUsers eu;
|
||||
|
||||
if(!hnd || !mem_ctx || !dom_hnd)
|
||||
return;
|
||||
|
||||
ZERO_STRUCT(eu);
|
||||
eu.in.dom_hnd = dom_hnd;
|
||||
|
||||
while(cac_SamEnumUsers(hnd, mem_ctx, &eu))
|
||||
print_rid_list(eu.out.rids, eu.out.names, eu.out.num_users);
|
||||
|
||||
if(CAC_OP_FAILED(hnd->status))
|
||||
printerr("Could not enumerate users.", hnd->status);
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
CC=gcc
|
||||
INCLUDES= -I`pwd` -I../../../source/ -I../../../source/include -I../../../source/ubiqx
|
||||
|
||||
DEFS= -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
|
||||
#CFLAGS= -O -D_SAMBA_BUILD_ -gstabs -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER -Wdeclaration-after-statement -g $(INCLUDES) $(DEFS) -fPIC
|
||||
|
||||
CFLAGS= -g -Wall -ansi $(INCLUDES)
|
||||
|
||||
LDFLAGS=-L. -L../../bin/
|
||||
LIBS=../../../source/bin/libmsrpc.so
|
||||
|
||||
TESTS= lsapol lsaq lsaenum lsaenumprivs lsapriv ear \
|
||||
regkey regopenkey regkeyenum regvalenum regsetval regqueryval regdelete security \
|
||||
adduser samenum samlookup samgroup enable disable dominfo samuser \
|
||||
svc \
|
||||
smbc
|
||||
|
||||
all: $(TESTS)
|
||||
|
||||
lsapol: lsa/lsapol.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
|
||||
|
||||
lsapriv: lsa/lsapriv.o test_util.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS)
|
||||
|
||||
lsaq: lsa/lsaq.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
|
||||
|
||||
lsaenum: lsa/lsaenum.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
|
||||
|
||||
lsaenumprivs: lsa/lsaenumprivs.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
|
||||
|
||||
lsaaddrights: lsa/lsaaddrights.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
|
||||
|
||||
ear: lsa/ear.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
|
||||
|
||||
regkey: reg/regkey.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
|
||||
|
||||
regopenkey: reg/regopenkey.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
|
||||
|
||||
regkeyenum: reg/regkeyenum.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
|
||||
|
||||
regkeycreate: reg/regkeycreate.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
|
||||
|
||||
regvalenum: reg/regvalenum.o test_util.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS)
|
||||
|
||||
regsetval: reg/regsetval.o test_util.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS)
|
||||
|
||||
regqueryval: reg/regqueryval.o test_util.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS)
|
||||
|
||||
regdelete: reg/regdelete.o test_util.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS)
|
||||
|
||||
security: reg/security.o test_util.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS)
|
||||
|
||||
adduser: sam/adduser.o test_util.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS)
|
||||
|
||||
samenum: sam/samenum.o test_util.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS)
|
||||
|
||||
samlookup: sam/samlookup.o test_util.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS)
|
||||
|
||||
samgroup: sam/samgroup.o test_util.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS)
|
||||
|
||||
enable: sam/enable.o test_util.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS)
|
||||
|
||||
disable: sam/disable.o test_util.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS)
|
||||
|
||||
samuser: sam/samuser.o test_util.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS)
|
||||
|
||||
dominfo: sam/dominfo.o test_util.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS)
|
||||
|
||||
svc: svcctl/svc.o test_util.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS)
|
||||
|
||||
smbc: smbc_test/smbc.o test_util.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< test_util.o $(LIBS) ../../../source/bin/libsmbclient.so
|
||||
|
||||
clean:
|
||||
rm -f $(TESTS) *.o lsa/*.o reg/*.o sam/*.o
|
@ -1,8 +0,0 @@
|
||||
This code was written to test the different library functions. However, a simple example of almost every libmsrpc call can be found
|
||||
in this code.
|
||||
|
||||
notes: most of the programs use a modified smbc_get_auth_data_fn which will not prompt for a user/domain/password so expect flaky results
|
||||
if you run the tests with just a server, ie: svc remote_machine
|
||||
|
||||
|
||||
If you get errors about the libmsrpc.so object, make sure your LD_LIBRARY_PATH points to /path/to/samba3/source/bin
|
@ -1,261 +0,0 @@
|
||||
/* connects to an LSA, asks for a list of server names, prints out their sids, then looks up their names from the sids and prints them out again
|
||||
* if you run as lsaq -p, then it will simulate a partial success for cac_GetNamesFromSids. It will try to lookup the server's local and domain sids
|
||||
*/
|
||||
|
||||
|
||||
#include "libmsrpc.h"
|
||||
#include "includes.h"
|
||||
|
||||
void fill_conn_info(CacServerHandle *hnd) {
|
||||
pstring domain;
|
||||
pstring username;
|
||||
pstring password;
|
||||
pstring server;
|
||||
|
||||
fprintf(stdout, "Enter domain name: ");
|
||||
fscanf(stdin, "%s", domain);
|
||||
|
||||
fprintf(stdout, "Enter username: ");
|
||||
fscanf(stdin, "%s", username);
|
||||
|
||||
fprintf(stdout, "Enter password (no input masking): ");
|
||||
fscanf(stdin, "%s", password);
|
||||
|
||||
fprintf(stdout, "Enter server (ip or name): ");
|
||||
fscanf(stdin, "%s", server);
|
||||
|
||||
hnd->domain = SMB_STRDUP(domain);
|
||||
hnd->username = SMB_STRDUP(username);
|
||||
hnd->password = SMB_STRDUP(password);
|
||||
hnd->server = SMB_STRDUP(server);
|
||||
}
|
||||
|
||||
void get_server_names(TALLOC_CTX *mem_ctx, int *num_names, char ***names) {
|
||||
int i = 0;
|
||||
pstring tmp;
|
||||
|
||||
fprintf(stdout, "How many names do you want to lookup?: ");
|
||||
fscanf(stdin, "%d", num_names);
|
||||
|
||||
*names = TALLOC_ARRAY(mem_ctx, char *, *num_names);
|
||||
if(*names == NULL) {
|
||||
fprintf(stderr, "No memory for allocation\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
for(i = 0; i < *num_names; i++) {
|
||||
fprintf(stdout, "Enter name: ");
|
||||
fscanf(stdin, "%s", tmp);
|
||||
(*names)[i] = talloc_strdup(mem_ctx, tmp);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int i;
|
||||
int result;
|
||||
char **names;
|
||||
int num_names;
|
||||
int num_sids;
|
||||
CacServerHandle *hnd = NULL;
|
||||
POLICY_HND *lsa_pol = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
DOM_SID *sid_buf = NULL;
|
||||
|
||||
BOOL sim_partial = False;
|
||||
|
||||
if(argc > 1 && strcmp(argv[1], "-p") == 0)
|
||||
sim_partial = True;
|
||||
|
||||
mem_ctx = talloc_init("lsaq");
|
||||
|
||||
hnd = cac_NewServerHandle(False);
|
||||
|
||||
fill_conn_info(hnd);
|
||||
|
||||
get_server_names(mem_ctx, &num_names, &names);
|
||||
|
||||
/*connect to the PDC and open a LSA handle*/
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server.\n Error %s.\n", nt_errstr(hnd->status));
|
||||
cac_FreeHandle(hnd);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
fprintf(stdout, "Connected to server: %s\n", hnd->server);
|
||||
|
||||
struct LsaOpenPolicy lop;
|
||||
ZERO_STRUCT(lop);
|
||||
|
||||
lop.in.access = SEC_RIGHT_MAXIMUM_ALLOWED;
|
||||
lop.in.security_qos = True;
|
||||
|
||||
if(!cac_LsaOpenPolicy(hnd, mem_ctx, &lop)) {
|
||||
fprintf(stderr, "Could not get lsa policy handle.\n Error: %s\n", nt_errstr(hnd->status));
|
||||
cac_FreeHandle(hnd);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
fprintf(stdout, "Opened Policy Handle\n");
|
||||
|
||||
/*just to make things neater*/
|
||||
lsa_pol = lop.out.pol;
|
||||
|
||||
/*fetch the local sid and domain sid for the pdc*/
|
||||
|
||||
struct LsaFetchSid fsop;
|
||||
ZERO_STRUCT(fsop);
|
||||
|
||||
fsop.in.pol = lsa_pol;
|
||||
fsop.in.info_class = (CAC_LOCAL_INFO|CAC_DOMAIN_INFO);
|
||||
|
||||
fprintf(stdout, "fetching SID info for %s\n", hnd->server);
|
||||
|
||||
result = cac_LsaFetchSid(hnd, mem_ctx, &fsop);
|
||||
if(!result) {
|
||||
fprintf(stderr, "Could not get sid for server: %s\n. Error: %s\n", hnd->server, nt_errstr(hnd->status));
|
||||
cac_FreeHandle(hnd);
|
||||
talloc_destroy(mem_ctx);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if(result == CAC_PARTIAL_SUCCESS) {
|
||||
fprintf(stdout, "could not retrieve both domain and local information\n");
|
||||
}
|
||||
|
||||
|
||||
fprintf(stdout, "Fetched SID info for %s\n", hnd->server);
|
||||
if(fsop.out.local_sid != NULL)
|
||||
fprintf(stdout, " domain: %s. Local SID: %s\n", fsop.out.local_sid->domain, sid_string_static(&fsop.out.local_sid->sid));
|
||||
|
||||
if(fsop.out.domain_sid != NULL)
|
||||
fprintf(stdout, " domain: %s, Domain SID: %s\n", fsop.out.domain_sid->domain, sid_string_static(&fsop.out.domain_sid->sid));
|
||||
|
||||
fprintf(stdout, "Looking up sids\n");
|
||||
|
||||
|
||||
struct LsaGetSidsFromNames gsop;
|
||||
ZERO_STRUCT(gsop);
|
||||
|
||||
gsop.in.pol = lsa_pol;
|
||||
gsop.in.num_names = num_names;
|
||||
gsop.in.names = names;
|
||||
|
||||
result = cac_LsaGetSidsFromNames(hnd, mem_ctx, &gsop);
|
||||
|
||||
if(!result) {
|
||||
fprintf(stderr, "Could not lookup any sids!\n Error: %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
if(result == CAC_PARTIAL_SUCCESS) {
|
||||
fprintf(stdout, "Not all names could be looked up.\nThe following names were not found:\n");
|
||||
|
||||
for(i = 0; i < (num_names - gsop.out.num_found); i++) {
|
||||
fprintf(stdout, " %s\n", gsop.out.unknown[i]);
|
||||
}
|
||||
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
|
||||
/*buffer the sids so we can look them up back to names*/
|
||||
num_sids = (sim_partial) ? gsop.out.num_found + 2: gsop.out.num_found;
|
||||
sid_buf = TALLOC_ARRAY(mem_ctx, DOM_SID, num_sids);
|
||||
|
||||
fprintf(stdout, "%d names were resolved: \n", gsop.out.num_found);
|
||||
|
||||
|
||||
i = 0;
|
||||
while(i < gsop.out.num_found) {
|
||||
fprintf(stdout, " Name: %s\n SID: %s\n\n", gsop.out.sids[i].name, sid_string_static(&gsop.out.sids[i].sid));
|
||||
|
||||
sid_buf[i] = gsop.out.sids[i].sid;
|
||||
|
||||
printf("Attempting to open account\n");
|
||||
|
||||
struct LsaOpenAccount loa;
|
||||
ZERO_STRUCT(loa);
|
||||
|
||||
loa.in.pol = lsa_pol;
|
||||
loa.in.access = SEC_RIGHT_MAXIMUM_ALLOWED;
|
||||
loa.in.sid = &gsop.out.sids[i].sid;
|
||||
|
||||
if(!cac_LsaOpenAccount(hnd, mem_ctx, &loa)) {
|
||||
fprintf(stderr, "Could not open account.\n Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
|
||||
printf("\nEnumerating privs:");
|
||||
struct LsaEnumAccountRights earop;
|
||||
ZERO_STRUCT(earop);
|
||||
|
||||
earop.in.pol = lsa_pol;
|
||||
|
||||
earop.in.sid = &gsop.out.sids[i].sid;
|
||||
|
||||
if(!cac_LsaEnumAccountRights(hnd, mem_ctx, &earop)) {
|
||||
fprintf(stderr, "Could not enumerate account rights.\n Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
|
||||
int j;
|
||||
printf( "Rights: ");
|
||||
for(j = 0; j < earop.out.num_privs; j++) {
|
||||
printf(" %s\n", earop.out.priv_names[j]);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
/*if we want a partial success to occur below, then add the server's SIDs to the end of the array*/
|
||||
if(sim_partial) {
|
||||
sid_buf[i] = fsop.out.local_sid->sid;
|
||||
sid_buf[i+1] = fsop.out.domain_sid->sid;
|
||||
}
|
||||
|
||||
fprintf(stdout, "Looking up Names from SIDs\n");
|
||||
|
||||
struct LsaGetNamesFromSids gnop;
|
||||
ZERO_STRUCT(gnop);
|
||||
|
||||
gnop.in.pol = lsa_pol;
|
||||
gnop.in.num_sids = num_sids;
|
||||
gnop.in.sids = sid_buf;
|
||||
|
||||
result = cac_LsaGetNamesFromSids(hnd, mem_ctx, &gnop);
|
||||
|
||||
if(!result) {
|
||||
fprintf(stderr, "Could not lookup any names!.\n Error: %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
if(result == CAC_PARTIAL_SUCCESS) {
|
||||
fprintf(stdout, "\nNot all SIDs could be looked up.\n. The following SIDs were not found:\n");
|
||||
|
||||
for(i = 0; i < (num_sids - gnop.out.num_found); i++) {
|
||||
fprintf(stdout, "SID: %s\n", sid_string_static(&gnop.out.unknown[i]));
|
||||
}
|
||||
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
|
||||
fprintf(stdout, "%d SIDs were resolved: \n", gnop.out.num_found);
|
||||
for(i = 0; i < gnop.out.num_found; i++) {
|
||||
fprintf(stdout, " SID: %s\n Name: %s\n", sid_string_static(&gnop.out.sids[i].sid), gsop.out.sids[i].name);
|
||||
}
|
||||
|
||||
done:
|
||||
|
||||
if(!cac_LsaClosePolicy(hnd, mem_ctx, lsa_pol)) {
|
||||
fprintf(stderr, "Could not close LSA policy handle.\n Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
fprintf(stdout, "Closed Policy handle.\n");
|
||||
}
|
||||
|
||||
cac_FreeHandle(hnd);
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
/*enumerates SIDs*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
#include "includes.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
POLICY_HND *pol = NULL;
|
||||
|
||||
int i;
|
||||
int max_sids;
|
||||
|
||||
mem_ctx = talloc_init("lsaenum");
|
||||
|
||||
hnd = cac_NewServerHandle(True);
|
||||
|
||||
printf("Enter server to connect to: ");
|
||||
fscanf(stdin, "%s", hnd->server);
|
||||
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server.\n Error: %s.\n errno: %s\n", nt_errstr(hnd->status), strerror(errno));
|
||||
cac_FreeHandle(hnd);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
printf("How many sids do you want to grab at a time? ");
|
||||
fscanf(stdin, "%d", &max_sids);
|
||||
|
||||
struct LsaOpenPolicy lop;
|
||||
ZERO_STRUCT(lop);
|
||||
|
||||
lop.in.access = SEC_RIGHT_MAXIMUM_ALLOWED;
|
||||
lop.in.security_qos = True;
|
||||
|
||||
|
||||
if(!cac_LsaOpenPolicy(hnd, mem_ctx, &lop)) {
|
||||
fprintf(stderr, "Could not open policy handle.\n Error: %s\n", nt_errstr(hnd->status));
|
||||
cac_FreeHandle(hnd);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
pol = lop.out.pol;
|
||||
|
||||
|
||||
struct LsaEnumSids esop;
|
||||
ZERO_STRUCT(esop);
|
||||
esop.in.pol = pol;
|
||||
/*grab a couple at a time to demonstrate multiple calls*/
|
||||
esop.in.pref_max_sids = max_sids;
|
||||
|
||||
printf("Attempting to fetch SIDs %d at a time\n", esop.in.pref_max_sids);
|
||||
|
||||
while(cac_LsaEnumSids(hnd, mem_ctx, &esop)) {
|
||||
|
||||
printf("\nEnumerated %d sids: \n", esop.out.num_sids);
|
||||
for(i = 0; i < esop.out.num_sids; i++) {
|
||||
printf(" SID: %s\n", sid_string_static(&esop.out.sids[i]));
|
||||
}
|
||||
|
||||
printf("Resolving names\n");
|
||||
|
||||
struct LsaGetNamesFromSids gnop;
|
||||
ZERO_STRUCT(gnop);
|
||||
|
||||
gnop.in.pol = pol;
|
||||
gnop.in.sids = esop.out.sids;
|
||||
gnop.in.num_sids = esop.out.num_sids;
|
||||
|
||||
if(!cac_LsaGetNamesFromSids(hnd, mem_ctx, &gnop)) {
|
||||
fprintf(stderr, "Could not resolve names.\n Error: %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
printf("\nResolved %d names: \n", gnop.out.num_found);
|
||||
for(i = 0; i < gnop.out.num_found; i++) {
|
||||
printf(" SID: %s\n", sid_string_static(&gnop.out.sids[i].sid));
|
||||
printf(" Name: %s\n", gnop.out.sids[i].name);
|
||||
}
|
||||
|
||||
/*clean up a little*/
|
||||
talloc_free(gnop.out.sids);
|
||||
}
|
||||
|
||||
done:
|
||||
if(!cac_LsaClosePolicy(hnd, mem_ctx, pol)) {
|
||||
fprintf(stderr, "Could not close policy handle.\n Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
|
||||
cac_FreeHandle(hnd);
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
/*enumerates privileges*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
#include "includes.h"
|
||||
|
||||
#define MAX_STRING_LEN 50;
|
||||
|
||||
int main() {
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
POLICY_HND *lsa_pol = NULL;
|
||||
|
||||
int i;
|
||||
|
||||
mem_ctx = talloc_init("lsatrust");
|
||||
|
||||
hnd = cac_NewServerHandle(True);
|
||||
|
||||
printf("Server: ");
|
||||
fscanf(stdin, "%s", hnd->server);
|
||||
|
||||
printf("Connecting to server....\n");
|
||||
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server.\n Error: %s\n errno %s\n", nt_errstr(hnd->status), strerror(errno));
|
||||
cac_FreeHandle(hnd);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
printf("Connected to server\n");
|
||||
|
||||
struct LsaOpenPolicy lop;
|
||||
ZERO_STRUCT(lop);
|
||||
|
||||
lop.in.access = SEC_RIGHT_MAXIMUM_ALLOWED;
|
||||
lop.in.security_qos = True;
|
||||
|
||||
|
||||
if(!cac_LsaOpenPolicy(hnd, mem_ctx, &lop)) {
|
||||
fprintf(stderr, "Could not open policy handle.\n Error: %s\n", nt_errstr(hnd->status));
|
||||
cac_FreeHandle(hnd);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
lsa_pol = lop.out.pol;
|
||||
|
||||
printf("Enumerating Privileges\n");
|
||||
|
||||
struct LsaEnumPrivileges ep;
|
||||
ZERO_STRUCT(ep);
|
||||
|
||||
ep.in.pol = lsa_pol;
|
||||
ep.in.pref_max_privs = 50;
|
||||
|
||||
while(cac_LsaEnumPrivileges(hnd, mem_ctx, &ep)) {
|
||||
printf(" Enumerated %d privileges\n", ep.out.num_privs);
|
||||
|
||||
for(i = 0; i < ep.out.num_privs; i++) {
|
||||
printf("\"%s\"\n", ep.out.priv_names[i]);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
if(CAC_OP_FAILED(hnd->status)) {
|
||||
fprintf(stderr, "Error while enumerating privileges.\n Error: %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
if(!cac_LsaClosePolicy(hnd, mem_ctx, lsa_pol)) {
|
||||
fprintf(stderr, "Could not close policy handle.\n Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
|
||||
cac_FreeHandle(hnd);
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
/* simple test code, opens and closes an LSA policy handle using libmsrpc, careful.. there's no password input masking*/
|
||||
|
||||
#include "includes.h"
|
||||
#include "libmsrpc.h"
|
||||
|
||||
void fill_conn_info(CacServerHandle *hnd) {
|
||||
pstring domain;
|
||||
pstring username;
|
||||
pstring password;
|
||||
pstring server;
|
||||
|
||||
fprintf(stdout, "Enter domain name: ");
|
||||
fscanf(stdin, "%s", domain);
|
||||
|
||||
fprintf(stdout, "Enter username: ");
|
||||
fscanf(stdin, "%s", username);
|
||||
|
||||
fprintf(stdout, "Enter password (no input masking): ");
|
||||
fscanf(stdin, "%s", password);
|
||||
|
||||
fprintf(stdout, "Enter server (ip or name): ");
|
||||
fscanf(stdin, "%s", server);
|
||||
|
||||
hnd->domain = SMB_STRDUP(domain);
|
||||
hnd->username = SMB_STRDUP(username);
|
||||
hnd->password = SMB_STRDUP(password);
|
||||
hnd->server = SMB_STRDUP(server);
|
||||
}
|
||||
|
||||
int main() {
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx;
|
||||
struct LsaOpenPolicy op;
|
||||
|
||||
mem_ctx = talloc_init("lsapol");
|
||||
|
||||
|
||||
hnd = cac_NewServerHandle(False);
|
||||
|
||||
/*this line is unnecesary*/
|
||||
cac_SetAuthDataFn(hnd, cac_GetAuthDataFn);
|
||||
|
||||
hnd->debug = 0;
|
||||
|
||||
fill_conn_info(hnd);
|
||||
|
||||
/*connect to the server, its name/ip is already in the handle so just pass NULL*/
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server. \n Error %s\n errno(%d): %s\n", nt_errstr(hnd->status), errno, strerror(errno));
|
||||
cac_FreeHandle(hnd);
|
||||
exit(-1);
|
||||
}
|
||||
else {
|
||||
fprintf(stdout, "Connected to server\n");
|
||||
}
|
||||
|
||||
op.in.access = GENERIC_EXECUTE_ACCESS;
|
||||
op.in.security_qos = True;
|
||||
|
||||
/*open the handle*/
|
||||
if(!cac_LsaOpenPolicy(hnd, mem_ctx, &op)) {
|
||||
fprintf(stderr, "Could not open policy.\n Error: %s.errno: %d.\n", nt_errstr(hnd->status), errno);
|
||||
cac_FreeHandle(hnd);
|
||||
exit(-1);
|
||||
}
|
||||
else {
|
||||
fprintf(stdout, "Opened Policy handle\n");
|
||||
}
|
||||
|
||||
/*close the handle*/
|
||||
if(!cac_LsaClosePolicy(hnd, mem_ctx, op.out.pol)) {
|
||||
fprintf(stderr, "Could not close policy. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
fprintf(stdout, "Closed Policy handle\n");
|
||||
}
|
||||
|
||||
/*cleanup*/
|
||||
cac_FreeHandle(hnd);
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
fprintf(stdout, "Free'd server handle\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,113 +0,0 @@
|
||||
/*tries to set privileges for an account*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
#include "test_util.h"
|
||||
|
||||
#define BIGGEST_UINT32 0xffffffff
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
struct LsaOpenPolicy lop;
|
||||
struct LsaEnumPrivileges ep;
|
||||
struct LsaEnumAccountRights ar;
|
||||
struct LsaAddPrivileges ap;
|
||||
|
||||
fstring tmp;
|
||||
|
||||
uint32 i = 0;
|
||||
|
||||
mem_ctx = talloc_init("lsapriv");
|
||||
|
||||
hnd = cac_NewServerHandle(True);
|
||||
|
||||
cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);
|
||||
|
||||
cac_parse_cmd_line(argc, argv, hnd);
|
||||
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
ZERO_STRUCT(lop);
|
||||
|
||||
lop.in.access = SEC_RIGHT_MAXIMUM_ALLOWED;
|
||||
|
||||
if(!cac_LsaOpenPolicy(hnd, mem_ctx, &lop)) {
|
||||
fprintf(stderr, "Could not open LSA policy. Error: %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*first enumerate possible privileges*/
|
||||
ZERO_STRUCT(ep);
|
||||
|
||||
ep.in.pol = lop.out.pol;
|
||||
ep.in.pref_max_privs = BIGGEST_UINT32;
|
||||
|
||||
printf("Enumerating supported privileges:\n");
|
||||
while(cac_LsaEnumPrivileges(hnd, mem_ctx, &ep)) {
|
||||
for(i = 0; i < ep.out.num_privs; i++) {
|
||||
printf("\t%s\n", ep.out.priv_names[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if(CAC_OP_FAILED(hnd->status)) {
|
||||
fprintf(stderr, "Could not enumerate privileges. Error: %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
printf("Enter account name: ");
|
||||
cactest_readline(stdin, tmp);
|
||||
|
||||
ZERO_STRUCT(ar);
|
||||
|
||||
ar.in.pol = lop.out.pol;
|
||||
ar.in.name = talloc_strdup(mem_ctx, tmp);
|
||||
|
||||
printf("Enumerating privileges for %s:\n", ar.in.name);
|
||||
if(!cac_LsaEnumAccountRights(hnd, mem_ctx, &ar)) {
|
||||
fprintf(stderr, "Could not enumerate privileges. Error: %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
printf("Enumerated %d privileges:\n", ar.out.num_privs);
|
||||
|
||||
for(i = 0; i < ar.out.num_privs; i++)
|
||||
printf("\t%s\n", ar.out.priv_names[i]);
|
||||
|
||||
ZERO_STRUCT(ap);
|
||||
|
||||
ap.in.pol = lop.out.pol;
|
||||
ap.in.name = ar.in.name;
|
||||
|
||||
printf("How many privileges will you set: ");
|
||||
scanf("%d", &ap.in.num_privs);
|
||||
|
||||
ap.in.priv_names = talloc_array(mem_ctx, char *, ap.in.num_privs);
|
||||
if(!ap.in.priv_names) {
|
||||
fprintf(stderr, "No memory\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
for(i = 0; i < ap.in.num_privs; i++) {
|
||||
printf("Enter priv %d: ", i);
|
||||
cactest_readline(stdin, tmp);
|
||||
|
||||
ap.in.priv_names[i] = talloc_strdup(mem_ctx, tmp);
|
||||
}
|
||||
|
||||
if(!cac_LsaSetPrivileges(hnd, mem_ctx, &ap)) {
|
||||
fprintf(stderr, "Could not set privileges. Error: %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
talloc_destroy(mem_ctx);
|
||||
cac_FreeHandle(hnd);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
@ -1,245 +0,0 @@
|
||||
/* connects to an LSA, asks for a list of server names, prints out their sids, then looks up their names from the sids and prints them out again
|
||||
* if you run as lsaq -p, then it will simulate a partial success for cac_GetNamesFromSids. It will try to lookup the server's local and domain sids
|
||||
*/
|
||||
|
||||
|
||||
#include "libmsrpc.h"
|
||||
#include "includes.h"
|
||||
|
||||
void fill_conn_info(CacServerHandle *hnd) {
|
||||
pstring domain;
|
||||
pstring username;
|
||||
pstring password;
|
||||
pstring server;
|
||||
|
||||
fprintf(stdout, "Enter domain name: ");
|
||||
fscanf(stdin, "%s", domain);
|
||||
|
||||
fprintf(stdout, "Enter username: ");
|
||||
fscanf(stdin, "%s", username);
|
||||
|
||||
fprintf(stdout, "Enter password (no input masking): ");
|
||||
fscanf(stdin, "%s", password);
|
||||
|
||||
fprintf(stdout, "Enter server (ip or name): ");
|
||||
fscanf(stdin, "%s", server);
|
||||
|
||||
hnd->domain = SMB_STRDUP(domain);
|
||||
hnd->username = SMB_STRDUP(username);
|
||||
hnd->password = SMB_STRDUP(password);
|
||||
hnd->server = SMB_STRDUP(server);
|
||||
}
|
||||
|
||||
void get_server_names(TALLOC_CTX *mem_ctx, int *num_names, char ***names) {
|
||||
int i = 0;
|
||||
pstring tmp;
|
||||
|
||||
fprintf(stdout, "How many names do you want to lookup?: ");
|
||||
fscanf(stdin, "%d", num_names);
|
||||
|
||||
*names = TALLOC_ARRAY(mem_ctx, char *, *num_names);
|
||||
if(*names == NULL) {
|
||||
fprintf(stderr, "No memory for allocation\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
for(i = 0; i < *num_names; i++) {
|
||||
fprintf(stdout, "Enter name: ");
|
||||
fscanf(stdin, "%s", tmp);
|
||||
(*names)[i] = talloc_strdup(mem_ctx, tmp);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int i;
|
||||
int result;
|
||||
char **names;
|
||||
int num_names;
|
||||
int num_sids;
|
||||
CacServerHandle *hnd = NULL;
|
||||
POLICY_HND *lsa_pol = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
DOM_SID *sid_buf = NULL;
|
||||
|
||||
BOOL sim_partial = False;
|
||||
|
||||
if(argc > 1 && strcmp(argv[1], "-p") == 0)
|
||||
sim_partial = True;
|
||||
|
||||
mem_ctx = talloc_init("lsaq");
|
||||
|
||||
hnd = cac_NewServerHandle(False);
|
||||
|
||||
fill_conn_info(hnd);
|
||||
|
||||
get_server_names(mem_ctx, &num_names, &names);
|
||||
|
||||
/*connect to the PDC and open a LSA handle*/
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server.\n Error %s.\n", nt_errstr(hnd->status));
|
||||
cac_FreeHandle(hnd);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
fprintf(stdout, "Connected to server: %s\n", hnd->server);
|
||||
|
||||
struct LsaOpenPolicy lop;
|
||||
ZERO_STRUCT(lop);
|
||||
|
||||
lop.in.access = SEC_RIGHT_MAXIMUM_ALLOWED;
|
||||
lop.in.security_qos = True;
|
||||
|
||||
if(!cac_LsaOpenPolicy(hnd, mem_ctx, &lop)) {
|
||||
fprintf(stderr, "Could not get lsa policy handle.\n Error: %s\n", nt_errstr(hnd->status));
|
||||
cac_FreeHandle(hnd);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
fprintf(stdout, "Opened Policy Handle\n");
|
||||
|
||||
/*just to make things neater*/
|
||||
lsa_pol = lop.out.pol;
|
||||
|
||||
/*fetch the local sid and domain sid for the pdc*/
|
||||
|
||||
struct LsaFetchSid fsop;
|
||||
ZERO_STRUCT(fsop);
|
||||
|
||||
fsop.in.pol = lsa_pol;
|
||||
fsop.in.info_class = (CAC_LOCAL_INFO|CAC_DOMAIN_INFO);
|
||||
|
||||
fprintf(stdout, "fetching SID info for %s\n", hnd->server);
|
||||
|
||||
result = cac_LsaFetchSid(hnd, mem_ctx, &fsop);
|
||||
if(!result) {
|
||||
fprintf(stderr, "Could not get sid for server: %s\n. Error: %s\n", hnd->server, nt_errstr(hnd->status));
|
||||
cac_FreeHandle(hnd);
|
||||
talloc_destroy(mem_ctx);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if(result == CAC_PARTIAL_SUCCESS) {
|
||||
fprintf(stdout, "could not retrieve both domain and local information\n");
|
||||
}
|
||||
|
||||
|
||||
fprintf(stdout, "Fetched SID info for %s\n", hnd->server);
|
||||
if(fsop.out.local_sid != NULL)
|
||||
fprintf(stdout, " domain: %s. Local SID: %s\n", fsop.out.local_sid->domain, sid_string_static(&fsop.out.local_sid->sid));
|
||||
|
||||
if(fsop.out.domain_sid != NULL)
|
||||
fprintf(stdout, " domain: %s, Domain SID: %s\n", fsop.out.domain_sid->domain, sid_string_static(&fsop.out.domain_sid->sid));
|
||||
|
||||
fprintf(stdout, "\nAttempting to query info policy\n");
|
||||
|
||||
struct LsaQueryInfoPolicy qop;
|
||||
ZERO_STRUCT(qop);
|
||||
|
||||
qop.in.pol = lsa_pol;
|
||||
|
||||
if(!cac_LsaQueryInfoPolicy(hnd, mem_ctx, &qop)) {
|
||||
fprintf(stderr, "Could not query information policy!.\n Error: %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
fprintf(stdout, "Query result: \n");
|
||||
fprintf(stdout, " domain name: %s\n", qop.out.domain_name);
|
||||
fprintf(stdout, " dns name: %s\n", qop.out.dns_name);
|
||||
fprintf(stdout, " forest name: %s\n", qop.out.forest_name);
|
||||
fprintf(stdout, " domain guid: %s\n", smb_uuid_string_static(*qop.out.domain_guid));
|
||||
fprintf(stdout, " domain sid: %s\n", sid_string_static(qop.out.domain_sid));
|
||||
|
||||
fprintf(stdout, "\nLooking up sids\n");
|
||||
|
||||
struct LsaGetSidsFromNames gsop;
|
||||
ZERO_STRUCT(gsop);
|
||||
|
||||
gsop.in.pol = lsa_pol;
|
||||
gsop.in.num_names = num_names;
|
||||
gsop.in.names = names;
|
||||
|
||||
result = cac_LsaGetSidsFromNames(hnd, mem_ctx, &gsop);
|
||||
|
||||
if(!result) {
|
||||
fprintf(stderr, "Could not lookup any sids!\n Error: %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
if(result == CAC_PARTIAL_SUCCESS) {
|
||||
fprintf(stdout, "Not all names could be looked up.\nThe following names were not found:\n");
|
||||
|
||||
for(i = 0; i < (num_names - gsop.out.num_found); i++) {
|
||||
fprintf(stdout, " %s\n", gsop.out.unknown[i]);
|
||||
}
|
||||
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
|
||||
/*buffer the sids so we can look them up back to names*/
|
||||
num_sids = (sim_partial) ? gsop.out.num_found + 2: gsop.out.num_found;
|
||||
sid_buf = TALLOC_ARRAY(mem_ctx, DOM_SID, num_sids);
|
||||
|
||||
fprintf(stdout, "%d names were resolved: \n", gsop.out.num_found);
|
||||
|
||||
|
||||
i = 0;
|
||||
while(i < gsop.out.num_found) {
|
||||
fprintf(stdout, " Name: %s\n SID: %s\n\n", gsop.out.sids[i].name, sid_string_static(&gsop.out.sids[i].sid));
|
||||
|
||||
sid_buf[i] = gsop.out.sids[i].sid;
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
/*if we want a partial success to occur below, then add the server's SIDs to the end of the array*/
|
||||
if(sim_partial) {
|
||||
sid_buf[i] = fsop.out.local_sid->sid;
|
||||
sid_buf[i+1] = fsop.out.domain_sid->sid;
|
||||
}
|
||||
|
||||
fprintf(stdout, "Looking up Names from SIDs\n");
|
||||
|
||||
struct LsaGetNamesFromSids gnop;
|
||||
ZERO_STRUCT(gnop);
|
||||
|
||||
gnop.in.pol = lsa_pol;
|
||||
gnop.in.num_sids = num_sids;
|
||||
gnop.in.sids = sid_buf;
|
||||
|
||||
result = cac_LsaGetNamesFromSids(hnd, mem_ctx, &gnop);
|
||||
|
||||
if(!result) {
|
||||
fprintf(stderr, "Could not lookup any names!.\n Error: %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
if(result == CAC_PARTIAL_SUCCESS) {
|
||||
fprintf(stdout, "\nNot all SIDs could be looked up.\n. The following SIDs were not found:\n");
|
||||
|
||||
for(i = 0; i < (num_sids - gnop.out.num_found); i++) {
|
||||
fprintf(stdout, "SID: %s\n", sid_string_static(&gnop.out.unknown[i]));
|
||||
}
|
||||
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
|
||||
fprintf(stdout, "%d SIDs were resolved: \n", gnop.out.num_found);
|
||||
for(i = 0; i < gnop.out.num_found; i++) {
|
||||
fprintf(stdout, " SID: %s\n Name: %s\n", sid_string_static(&gnop.out.sids[i].sid), gsop.out.sids[i].name);
|
||||
}
|
||||
|
||||
done:
|
||||
|
||||
if(!cac_LsaClosePolicy(hnd, mem_ctx, lsa_pol)) {
|
||||
fprintf(stderr, "Could not close LSA policy handle.\n Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
fprintf(stdout, "Closed Policy handle.\n");
|
||||
}
|
||||
|
||||
cac_FreeHandle(hnd);
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,151 +0,0 @@
|
||||
/*queries trusted domain information*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
#include "includes.h"
|
||||
|
||||
#define MAX_STRING_LEN 50;
|
||||
|
||||
void print_info(LSA_TRUSTED_DOMAIN_INFO *info) {
|
||||
switch(info->info_class) {
|
||||
case CAC_INFO_TRUSTED_DOMAIN_FULL_INFO:
|
||||
case CAC_INFO_TRUSTED_DOMAIN_INFO_ALL:
|
||||
printf(" Domain Name: %s\n", unistr2_static(&info->info_ex.domain_name.unistring));
|
||||
printf(" Netbios Name: %s\n", unistr2_static(&info->info_ex.netbios_name.unistring));
|
||||
printf(" Domain Sid: %s\n", sid_string_static(&info->info_ex.sid.sid));
|
||||
printf(" Trust direction: %d\n", info->info_ex.trust_direction);
|
||||
printf(" Trust Type: %d\n", info->info_ex.trust_type);
|
||||
printf(" Trust attr: %d\n", info->info_ex.trust_attributes);
|
||||
printf(" Posix Offset: %d\n", info->posix_offset.posix_offset);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
POLICY_HND *lsa_pol = NULL;
|
||||
|
||||
int i;
|
||||
|
||||
mem_ctx = talloc_init("lsatrust");
|
||||
|
||||
hnd = cac_NewServerHandle(False);
|
||||
|
||||
/*malloc some memory so get_auth_data_fn can work*/
|
||||
hnd->username = SMB_MALLOC_ARRAY(char, sizeof(fstring));
|
||||
hnd->domain = SMB_MALLOC_ARRAY(char, sizeof(fstring));
|
||||
hnd->netbios_name = SMB_MALLOC_ARRAY(char, sizeof(fstring));
|
||||
hnd->password = SMB_MALLOC_ARRAY(char, sizeof(fstring));
|
||||
|
||||
hnd->server = SMB_MALLOC_ARRAY(char, sizeof(fstring));
|
||||
|
||||
|
||||
printf("Server: ");
|
||||
fscanf(stdin, "%s", hnd->server);
|
||||
|
||||
printf("Connecting to server....\n");
|
||||
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server.\n Error: %s\n errno %s\n", nt_errstr(hnd->status), strerror(errno));
|
||||
cac_FreeHandle(hnd);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
printf("Connected to server\n");
|
||||
|
||||
struct LsaOpenPolicy lop;
|
||||
ZERO_STRUCT(lop);
|
||||
|
||||
lop.in.access = SEC_RIGHT_MAXIMUM_ALLOWED;
|
||||
lop.in.security_qos = True;
|
||||
|
||||
|
||||
if(!cac_LsaOpenPolicy(hnd, mem_ctx, &lop)) {
|
||||
fprintf(stderr, "Could not open policy handle.\n Error: %s\n", nt_errstr(hnd->status));
|
||||
cac_FreeHandle(hnd);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
lsa_pol = lop.out.pol;
|
||||
|
||||
printf("Enumerating Trusted Domains\n");
|
||||
|
||||
struct LsaEnumTrustedDomains etd;
|
||||
ZERO_STRUCT(etd);
|
||||
|
||||
etd.in.pol = lsa_pol;
|
||||
|
||||
while(cac_LsaEnumTrustedDomains(hnd, mem_ctx, &etd)) {
|
||||
printf(" Enumerated %d domains\n", etd.out.num_domains);
|
||||
|
||||
for(i = 0; i < etd.out.num_domains; i++) {
|
||||
printf(" Name: %s\n", etd.out.domain_names[i]);
|
||||
printf(" SID: %s\n", sid_string_static(&etd.out.domain_sids[i]));
|
||||
|
||||
printf("\n Attempting to open domain...\n");
|
||||
|
||||
struct LsaOpenTrustedDomain otd;
|
||||
ZERO_STRUCT(otd);
|
||||
|
||||
otd.in.pol = lsa_pol;
|
||||
otd.in.domain_sid = &etd.out.domain_sids[i];
|
||||
otd.in.access = SEC_RIGHT_MAXIMUM_ALLOWED;
|
||||
|
||||
/*try to query trusted domain info by name*/
|
||||
struct LsaQueryTrustedDomainInfo qtd;
|
||||
ZERO_STRUCT(qtd);
|
||||
|
||||
qtd.in.pol = lsa_pol;
|
||||
qtd.in.domain_name = etd.out.domain_names[i];
|
||||
|
||||
|
||||
int j;
|
||||
for(j = 0; j < 100; j++ ) {
|
||||
qtd.in.info_class = j;
|
||||
|
||||
printf(" Querying trustdom by name\n");
|
||||
if(!cac_LsaQueryTrustedDomainInfo(hnd, mem_ctx, &qtd)) {
|
||||
fprintf(stderr, " could not query trusted domain info.\n Error %s\n", nt_errstr(hnd->status));
|
||||
continue;
|
||||
}
|
||||
|
||||
printf(" info_class %d succeeded\n", j);
|
||||
printf(" Query result:\n");
|
||||
printf(" size %d\n", sizeof(*qtd.out.info));
|
||||
}
|
||||
|
||||
/*try to query trusted domain info by SID*/
|
||||
printf(" Querying trustdom by sid\n");
|
||||
qtd.in.domain_sid = &etd.out.domain_sids[i];
|
||||
if(!cac_LsaQueryTrustedDomainInfo(hnd, mem_ctx, &qtd)) {
|
||||
fprintf(stderr, " could not query trusted domain info.\n Error %s\n", nt_errstr(hnd->status));
|
||||
continue;
|
||||
}
|
||||
|
||||
printf(" Query result:\n");
|
||||
/* print_info(qtd.out.info);*/
|
||||
|
||||
if(CAC_OP_FAILED(hnd->status)) {
|
||||
fprintf(stderr, " Could not enum sids.\n Error: %s\n", nt_errstr(hnd->status));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
if(CAC_OP_FAILED(hnd->status)) {
|
||||
fprintf(stderr, "Error while enumerating trusted domains.\n Error: %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
if(!cac_LsaClosePolicy(hnd, mem_ctx, lsa_pol)) {
|
||||
fprintf(stderr, "Could not close policy handle.\n Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
|
||||
cac_FreeHandle(hnd);
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,102 +0,0 @@
|
||||
/*tests deleting a key or value*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
#include "test_util.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
fstring tmp;
|
||||
char input = 'v';
|
||||
|
||||
mem_ctx = talloc_init("regdelete");
|
||||
|
||||
hnd = cac_NewServerHandle(True);
|
||||
|
||||
cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);
|
||||
|
||||
cac_parse_cmd_line(argc, argv, hnd);
|
||||
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
printf("enter key to open: \n");
|
||||
cactest_readline(stdin, tmp);
|
||||
|
||||
struct RegOpenKey rok;
|
||||
ZERO_STRUCT(rok);
|
||||
|
||||
rok.in.name = talloc_strdup(mem_ctx, tmp);
|
||||
rok.in.access = REG_KEY_ALL;
|
||||
|
||||
if(!cac_RegOpenKey(hnd, mem_ctx, &rok)) {
|
||||
fprintf(stderr, "Could not open key %s. Error %s\n", rok.in.name, nt_errstr(hnd->status));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
printf("getting version (just for testing\n");
|
||||
|
||||
struct RegGetVersion rgv;
|
||||
ZERO_STRUCT(rgv);
|
||||
|
||||
rgv.in.key = rok.out.key;
|
||||
|
||||
if(!cac_RegGetVersion(hnd, mem_ctx, &rgv))
|
||||
fprintf(stderr, "Could not get version. Error: %s\n", nt_errstr(hnd->status));
|
||||
else
|
||||
printf("Version: %d\n", rgv.out.version);
|
||||
|
||||
|
||||
while(input == 'v' || input == 'k') {
|
||||
printf("Delete [v]alue [k]ey or [q]uit: ");
|
||||
scanf("%c", &input);
|
||||
|
||||
switch(input) {
|
||||
case 'v':
|
||||
printf("Value to delete: ");
|
||||
cactest_readline(stdin, tmp);
|
||||
|
||||
struct RegDeleteValue rdv;
|
||||
ZERO_STRUCT(rdv);
|
||||
|
||||
rdv.in.parent_key = rok.out.key;
|
||||
rdv.in.name = talloc_strdup(mem_ctx, tmp);
|
||||
|
||||
if(!cac_RegDeleteValue(hnd, mem_ctx, &rdv))
|
||||
fprintf(stderr, "Could not delete value %s. Error: %s\n", rdv.in.name, nt_errstr(hnd->status));
|
||||
|
||||
break;
|
||||
case 'k':
|
||||
printf("Key to delete: ");
|
||||
cactest_readline(stdin, tmp);
|
||||
|
||||
struct RegDeleteKey rdk;
|
||||
ZERO_STRUCT(rdk);
|
||||
|
||||
rdk.in.parent_key = rok.out.key;
|
||||
rdk.in.name = talloc_strdup(mem_ctx, tmp);
|
||||
|
||||
printf("delete recursively? [y/n]: ");
|
||||
cactest_readline(stdin, tmp);
|
||||
|
||||
rdk.in.recursive = (tmp[0] == 'y') ? True : False;
|
||||
|
||||
if(!cac_RegDeleteKey(hnd, mem_ctx, &rdk))
|
||||
fprintf(stderr, "Could not delete key %s. Error %s\n", rdk.in.name, nt_errstr(hnd->status));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
cac_RegClose(hnd, mem_ctx, rok.out.key);
|
||||
|
||||
cac_FreeHandle(hnd);
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,76 +0,0 @@
|
||||
/*opens and closes a key*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
|
||||
int main() {
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
fstring key;
|
||||
|
||||
mem_ctx = talloc_init("regkey");
|
||||
|
||||
hnd = cac_NewServerHandle(False);
|
||||
|
||||
/*allocate some memory so get_auth_data_fn can do it's magic*/
|
||||
hnd->username = SMB_MALLOC_ARRAY(char, sizeof(fstring));
|
||||
hnd->domain = SMB_MALLOC_ARRAY(char, sizeof(fstring));
|
||||
hnd->netbios_name = SMB_MALLOC_ARRAY(char, sizeof(fstring));
|
||||
hnd->password = SMB_MALLOC_ARRAY(char, sizeof(fstring));
|
||||
|
||||
hnd->server = SMB_MALLOC_ARRAY(char, sizeof(fstring));
|
||||
|
||||
printf("Enter server to connect to: ");
|
||||
fscanf(stdin, "%s", hnd->server);
|
||||
|
||||
printf("Enter key to open: ");
|
||||
fscanf(stdin, "%s", key);
|
||||
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server.\n Error: %s.\n errno: %s\n", nt_errstr(hnd->status), strerror(errno));
|
||||
cac_FreeHandle(hnd);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
struct RegConnect rc;
|
||||
ZERO_STRUCT(rc);
|
||||
|
||||
rc.in.access = REG_KEY_ALL;
|
||||
rc.in.root = HKEY_LOCAL_MACHINE;
|
||||
|
||||
if(!cac_RegConnect(hnd, mem_ctx, &rc)) {
|
||||
fprintf(stderr, " Could not connect to registry. %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
printf("trying to open key %s...\n", key);
|
||||
|
||||
|
||||
struct RegOpenKey rok;
|
||||
ZERO_STRUCT(rok);
|
||||
|
||||
rok.in.parent_key = rc.out.key;
|
||||
rok.in.name = key;
|
||||
rok.in.access = REG_KEY_ALL;
|
||||
|
||||
if(!cac_RegOpenKey(hnd, mem_ctx, &rok)) {
|
||||
fprintf(stderr, "Could not open key %s\n Error: %s\n", rok.in.name, nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
if(!cac_RegClose(hnd, mem_ctx, rok.out.key)) {
|
||||
fprintf(stderr, "Could not close handle %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
|
||||
if(!cac_RegClose(hnd, mem_ctx, rc.out.key)) {
|
||||
fprintf(stderr, " Could not close handle. %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
|
||||
done:
|
||||
cac_FreeHandle(hnd);
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
@ -1,115 +0,0 @@
|
||||
/*tests creating a registry key*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
|
||||
#define MAX_KEYS_PER_ENUM 3
|
||||
|
||||
int main() {
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
fstring key_name;
|
||||
|
||||
fstring key_to_create;
|
||||
|
||||
mem_ctx = talloc_init("regcreatekey");
|
||||
|
||||
hnd = cac_NewServerHandle(True);
|
||||
|
||||
printf("Enter server to connect to: ");
|
||||
fscanf(stdin, "%s", hnd->server);
|
||||
|
||||
printf("Enter key to open: ");
|
||||
fscanf(stdin, "%s", key_name);
|
||||
|
||||
printf("Enter key to create: ");
|
||||
fscanf(stdin, "%s", key_to_create);
|
||||
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server.\n Error: %s.\n errno: %s\n", nt_errstr(hnd->status), strerror(errno));
|
||||
cac_FreeHandle(hnd);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
printf("trying to open key %s...\n", key_name);
|
||||
|
||||
struct RegOpenKey rok;
|
||||
ZERO_STRUCT(rok);
|
||||
|
||||
rok.in.parent_key = NULL;
|
||||
rok.in.name = key_name;
|
||||
rok.in.access = REG_KEY_ALL;
|
||||
|
||||
if(!cac_RegOpenKey(hnd, mem_ctx, &rok)) {
|
||||
fprintf(stderr, "Could not open key %s\n Error: %s\n", rok.in.name, nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
printf("Creating key %s...\n", key_to_create);
|
||||
|
||||
struct RegCreateKey rck;
|
||||
ZERO_STRUCT(rck);
|
||||
|
||||
rck.in.parent_key = rok.out.key;
|
||||
rck.in.key_name = talloc_strdup(mem_ctx, key_to_create);
|
||||
rck.in.class_name = talloc_strdup(mem_ctx, "");
|
||||
rck.in.access = REG_KEY_ALL;
|
||||
|
||||
if(!cac_RegCreateKey(hnd, mem_ctx, &rck)) {
|
||||
fprintf(stderr, "Could not create key. Error %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
if(!cac_RegClose(hnd, mem_ctx, rck.out.key)) {
|
||||
fprintf(stderr, "Could not close key. Error %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
/**enumerate all the subkeys*/
|
||||
printf("Enumerating all subkeys:\n");
|
||||
|
||||
struct RegEnumKeys ek;
|
||||
ZERO_STRUCT(ek);
|
||||
|
||||
ek.in.key = rok.out.key;
|
||||
ek.in.max_keys = 50;
|
||||
|
||||
while(cac_RegEnumKeys(hnd, mem_ctx, &ek)) {
|
||||
int j;
|
||||
|
||||
for(j = 0; j < ek.out.num_keys; j++) {
|
||||
printf(" Key name: %s\n", ek.out.key_names[j]);
|
||||
}
|
||||
}
|
||||
|
||||
if(CAC_OP_FAILED(hnd->status)) {
|
||||
fprintf(stderr, "Could not enumerate keys: %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
printf("deleting key %s\n", key_to_create);
|
||||
|
||||
struct RegDeleteKey rdk;
|
||||
ZERO_STRUCT(rdk);
|
||||
|
||||
rdk.in.parent_key = rok.out.key;
|
||||
rdk.in.name = key_to_create;
|
||||
|
||||
if(!cac_RegDeleteKey(hnd, mem_ctx, &rdk)) {
|
||||
fprintf(stderr, "Could not delete key. Error %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
|
||||
printf("closing key %s...\n", key_name);
|
||||
|
||||
if(!cac_RegClose(hnd, mem_ctx, rok.out.key)) {
|
||||
fprintf(stderr, "Could not close handle %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
|
||||
done:
|
||||
cac_FreeHandle(hnd);
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
/*tests enumerating keys or values*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
|
||||
#define MAX_KEYS_PER_ENUM 3
|
||||
|
||||
int main() {
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
int num_keys;
|
||||
|
||||
int max_enum;
|
||||
|
||||
int i;
|
||||
|
||||
fstring *key_names;
|
||||
|
||||
mem_ctx = talloc_init("regkeyenum");
|
||||
|
||||
hnd = cac_NewServerHandle(True);
|
||||
|
||||
printf("Enter server to connect to: ");
|
||||
fscanf(stdin, "%s", hnd->server);
|
||||
|
||||
printf("How many keys do you want to open?: ");
|
||||
fscanf(stdin, "%d", &num_keys);
|
||||
|
||||
printf("How many keys per enum?: ");
|
||||
fscanf(stdin, "%d", &max_enum);
|
||||
|
||||
key_names = TALLOC_ARRAY(mem_ctx, fstring , num_keys);
|
||||
if(!key_names) {
|
||||
fprintf(stderr, "No memory\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
for(i = 0; i < num_keys; i++) {
|
||||
printf("Enter key to open: ");
|
||||
fscanf(stdin, "%s", key_names[i]);
|
||||
}
|
||||
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server.\n Error: %s.\n errno: %s\n", nt_errstr(hnd->status), strerror(errno));
|
||||
cac_FreeHandle(hnd);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
for(i = 0; i < num_keys; i++) {
|
||||
printf("trying to open key %s...\n", key_names[i]);
|
||||
|
||||
struct RegOpenKey rok;
|
||||
ZERO_STRUCT(rok);
|
||||
|
||||
rok.in.parent_key = NULL;
|
||||
rok.in.name = key_names[i];
|
||||
rok.in.access = REG_KEY_ALL;
|
||||
|
||||
if(!cac_RegOpenKey(hnd, mem_ctx, &rok)) {
|
||||
fprintf(stderr, "Could not open key %s\n Error: %s\n", rok.in.name, nt_errstr(hnd->status));
|
||||
continue;
|
||||
}
|
||||
|
||||
/**enumerate all the subkeys*/
|
||||
printf("Enumerating all subkeys:\n");
|
||||
|
||||
struct RegEnumKeys ek;
|
||||
ZERO_STRUCT(ek);
|
||||
|
||||
ek.in.key = rok.out.key;
|
||||
ek.in.max_keys = max_enum;
|
||||
|
||||
while(cac_RegEnumKeys(hnd, mem_ctx, &ek)) {
|
||||
int j;
|
||||
|
||||
for(j = 0; j < ek.out.num_keys; j++) {
|
||||
printf(" Key name: %s\n", ek.out.key_names[j]);
|
||||
}
|
||||
}
|
||||
|
||||
if(CAC_OP_FAILED(hnd->status)) {
|
||||
fprintf(stderr, "Could not enumerate keys: %s\n", nt_errstr(hnd->status));
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("closing key %s...\n", key_names[i]);
|
||||
|
||||
if(!cac_RegClose(hnd, mem_ctx, rok.out.key)) {
|
||||
fprintf(stderr, "Could not close handle %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
}
|
||||
|
||||
cac_FreeHandle(hnd);
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/*opens and closes a registry handle*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
|
||||
int main() {
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
POLICY_HND **keys = NULL;
|
||||
|
||||
char roots[4][50] = { {CAC_HKCR}, {CAC_HKLM}, {CAC_HKU}, {CAC_HKPD} };
|
||||
|
||||
int i;
|
||||
|
||||
|
||||
mem_ctx = talloc_init("regopen");
|
||||
|
||||
hnd = cac_NewServerHandle(True);
|
||||
|
||||
keys = TALLOC_ARRAY(mem_ctx, POLICY_HND *, 4);
|
||||
|
||||
printf("Enter server to connect to: ");
|
||||
fscanf(stdin, "%s", hnd->server);
|
||||
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server.\n Error: %s.\n errno: %s\n", nt_errstr(hnd->status), strerror(errno));
|
||||
cac_FreeHandle(hnd);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
struct RegConnect rc;
|
||||
ZERO_STRUCT(rc);
|
||||
|
||||
rc.in.access = SEC_RIGHT_MAXIMUM_ALLOWED;
|
||||
|
||||
for(i = 0; i < 4; i++) {
|
||||
printf("opening: %s\n", roots[i]);
|
||||
|
||||
rc.in.root = roots[i];
|
||||
|
||||
if(!cac_RegConnect(hnd, mem_ctx, &rc)) {
|
||||
fprintf(stderr, " Could not connect to registry. %s\n", nt_errstr(hnd->status));
|
||||
continue;
|
||||
}
|
||||
|
||||
keys[i] = rc.out.key;
|
||||
}
|
||||
|
||||
for(i = 3; i >= 0; i--) {
|
||||
if(keys[i] == NULL)
|
||||
continue;
|
||||
|
||||
printf("closing: %s\n", roots[i]);
|
||||
|
||||
if(!cac_RegClose(hnd, mem_ctx, keys[i])) {
|
||||
fprintf(stderr, " Could not close handle. %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
}
|
||||
|
||||
cac_FreeHandle(hnd);
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
/*tests cac_RegOpenKey()*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
|
||||
int main() {
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
int num_keys;
|
||||
int i;
|
||||
|
||||
fstring *key_names;
|
||||
|
||||
mem_ctx = talloc_init("regopenkey");
|
||||
|
||||
hnd = cac_NewServerHandle(True);
|
||||
|
||||
printf("Enter server to connect to: ");
|
||||
fscanf(stdin, "%s", hnd->server);
|
||||
|
||||
printf("How many keys do you want to open?: ");
|
||||
fscanf(stdin, "%d", &num_keys);
|
||||
|
||||
key_names = TALLOC_ARRAY(mem_ctx, fstring , num_keys);
|
||||
if(!key_names) {
|
||||
fprintf(stderr, "No memory\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
for(i = 0; i < num_keys; i++) {
|
||||
printf("Enter key to open: ");
|
||||
fscanf(stdin, "%s", key_names[i]);
|
||||
}
|
||||
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server.\n Error: %s.\n errno: %s\n", nt_errstr(hnd->status), strerror(errno));
|
||||
cac_FreeHandle(hnd);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
for(i = 0; i < num_keys; i++) {
|
||||
printf("trying to open key %s...\n", key_names[i]);
|
||||
|
||||
struct RegOpenKey rok;
|
||||
ZERO_STRUCT(rok);
|
||||
|
||||
rok.in.parent_key = NULL;
|
||||
rok.in.name = key_names[i];
|
||||
rok.in.access = REG_KEY_ALL;
|
||||
|
||||
if(!cac_RegOpenKey(hnd, mem_ctx, &rok)) {
|
||||
fprintf(stderr, "Could not open key %s\n Error: %s\n", rok.in.name, nt_errstr(hnd->status));
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("closing key %s...\n", key_names[i]);
|
||||
|
||||
if(!cac_RegClose(hnd, mem_ctx, rok.out.key)) {
|
||||
fprintf(stderr, "Could not close handle %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
}
|
||||
|
||||
cac_FreeHandle(hnd);
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
/*tests cac_RegQueryValue()*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
#include "test_util.h"
|
||||
|
||||
#define MAX_KEYS_PER_ENUM 3
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
fstring key_name;
|
||||
|
||||
fstring val_name;
|
||||
|
||||
mem_ctx = talloc_init("regqueryval");
|
||||
|
||||
hnd = cac_NewServerHandle(True);
|
||||
|
||||
cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);
|
||||
|
||||
cac_parse_cmd_line(argc, argv, hnd);
|
||||
|
||||
printf("Enter key to open: ");
|
||||
fscanf(stdin, "%s", key_name);
|
||||
|
||||
printf("Enter value to query: ");
|
||||
fscanf(stdin, "%s", val_name);
|
||||
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server.\n Error: %s.\n errno: %s\n", nt_errstr(hnd->status), strerror(errno));
|
||||
cac_FreeHandle(hnd);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
printf("trying to open key %s...\n", key_name);
|
||||
|
||||
struct RegOpenKey rok;
|
||||
ZERO_STRUCT(rok);
|
||||
|
||||
rok.in.parent_key = NULL;
|
||||
rok.in.name = key_name;
|
||||
rok.in.access = REG_KEY_ALL;
|
||||
|
||||
if(!cac_RegOpenKey(hnd, mem_ctx, &rok)) {
|
||||
fprintf(stderr, "Could not open key %s\n Error: %s\n", rok.in.name, nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
struct RegQueryValue rqv;
|
||||
ZERO_STRUCT(rqv);
|
||||
|
||||
rqv.in.key = rok.out.key;
|
||||
rqv.in.val_name = talloc_strdup(mem_ctx, val_name);
|
||||
|
||||
printf("querying value %s...\n", rqv.in.val_name);
|
||||
if(!cac_RegQueryValue(hnd, mem_ctx, &rqv)) {
|
||||
fprintf(stderr, "Could not query value. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
printf("Queried value %s\n", rqv.in.val_name);
|
||||
print_value(rqv.out.type, rqv.out.data);
|
||||
}
|
||||
|
||||
|
||||
printf("closing key %s...\n", key_name);
|
||||
|
||||
if(!cac_RegClose(hnd, mem_ctx, rok.out.key)) {
|
||||
fprintf(stderr, "Could not close handle %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
|
||||
done:
|
||||
cac_FreeHandle(hnd);
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/*tests cac_RegSetVal()*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
#include "test_util.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
fstring tmp;
|
||||
|
||||
mem_ctx = talloc_init("regsetval");
|
||||
|
||||
hnd = cac_NewServerHandle(True);
|
||||
|
||||
cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);
|
||||
|
||||
cac_parse_cmd_line(argc, argv, hnd);
|
||||
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
printf("enter key to open: \n");
|
||||
scanf("%s", tmp);
|
||||
|
||||
struct RegOpenKey rok;
|
||||
ZERO_STRUCT(rok);
|
||||
|
||||
rok.in.name = talloc_strdup(mem_ctx, tmp);
|
||||
rok.in.access = REG_KEY_ALL;
|
||||
|
||||
if(!cac_RegOpenKey(hnd, mem_ctx, &rok)) {
|
||||
fprintf(stderr, "Could not open key %s. Error %s\n", rok.in.name, nt_errstr(hnd->status));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
struct RegSetValue rsv;
|
||||
ZERO_STRUCT(rsv);
|
||||
|
||||
rsv.in.key = rok.out.key;
|
||||
|
||||
cactest_reg_input_val(mem_ctx, &rsv.in.type, &rsv.in.val_name, &rsv.in.value);
|
||||
|
||||
if(!cac_RegSetValue(hnd, mem_ctx, &rsv)) {
|
||||
fprintf(stderr, "Could not set value. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
|
||||
cac_RegClose(hnd, mem_ctx, rok.out.key);
|
||||
|
||||
cac_FreeHandle(hnd);
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,103 +0,0 @@
|
||||
/*tests enumerating registry values*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
#include "test_util.h"
|
||||
|
||||
#define MAX_KEYS_PER_ENUM 3
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
int num_keys;
|
||||
|
||||
int max_enum;
|
||||
|
||||
fstring *key_names;
|
||||
|
||||
int i;
|
||||
|
||||
mem_ctx = talloc_init("regvalenum");
|
||||
|
||||
hnd = cac_NewServerHandle(True);
|
||||
|
||||
cac_parse_cmd_line(argc, argv, hnd);
|
||||
|
||||
cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);
|
||||
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server.\n Error: %s.\n errno: %s\n", nt_errstr(hnd->status), strerror(errno));
|
||||
cac_FreeHandle(hnd);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
printf("How many keys do you want to open?: ");
|
||||
fscanf(stdin, "%d", &num_keys);
|
||||
|
||||
printf("How many values per enum?: ");
|
||||
fscanf(stdin, "%d", &max_enum);
|
||||
|
||||
key_names = TALLOC_ARRAY(mem_ctx, fstring , num_keys);
|
||||
if(!key_names) {
|
||||
fprintf(stderr, "No memory\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
for(i = 0; i < num_keys; i++) {
|
||||
printf("Enter key to open: ");
|
||||
fscanf(stdin, "%s", key_names[i]);
|
||||
}
|
||||
|
||||
for(i = 0; i < num_keys; i++) {
|
||||
printf("trying to open key %s...\n", key_names[i]);
|
||||
|
||||
struct RegOpenKey rok;
|
||||
ZERO_STRUCT(rok);
|
||||
|
||||
rok.in.parent_key = NULL;
|
||||
rok.in.name = key_names[i];
|
||||
rok.in.access = REG_KEY_ALL;
|
||||
|
||||
if(!cac_RegOpenKey(hnd, mem_ctx, &rok)) {
|
||||
fprintf(stderr, "Could not open key %s\n Error: %s\n", rok.in.name, nt_errstr(hnd->status));
|
||||
continue;
|
||||
}
|
||||
|
||||
/**enumerate all the subkeys*/
|
||||
printf("Enumerating all values:\n");
|
||||
|
||||
struct RegEnumValues rev;
|
||||
ZERO_STRUCT(rev);
|
||||
|
||||
rev.in.key = rok.out.key;
|
||||
rev.in.max_values = max_enum;
|
||||
|
||||
while(cac_RegEnumValues(hnd, mem_ctx, &rev)) {
|
||||
int j;
|
||||
|
||||
for(j = 0; j < rev.out.num_values; j++) {
|
||||
printf(" Value name: %s\n", rev.out.value_names[j]);
|
||||
print_value(rev.out.types[j], rev.out.values[j]);
|
||||
}
|
||||
}
|
||||
|
||||
if(CAC_OP_FAILED(hnd->status)) {
|
||||
fprintf(stderr, "Could not enumerate values: %s\n", nt_errstr(hnd->status));
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("closing key %s...\n", key_names[i]);
|
||||
|
||||
if(!cac_RegClose(hnd, mem_ctx, rok.out.key)) {
|
||||
fprintf(stderr, "Could not close handle %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
}
|
||||
|
||||
cac_FreeHandle(hnd);
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
/*tests cac_RegSetKeySecurity()*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
#include "test_util.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
fstring tmp;
|
||||
|
||||
mem_ctx = talloc_init("regsetval");
|
||||
|
||||
hnd = cac_NewServerHandle(True);
|
||||
|
||||
cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);
|
||||
|
||||
cac_parse_cmd_line(argc, argv, hnd);
|
||||
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
struct RegOpenKey rok;
|
||||
ZERO_STRUCT(rok);
|
||||
|
||||
printf("enter key to query: ");
|
||||
cactest_readline(stdin, tmp);
|
||||
|
||||
rok.in.name = talloc_strdup(mem_ctx, tmp);
|
||||
rok.in.access = REG_KEY_ALL;
|
||||
|
||||
if(!cac_RegOpenKey(hnd, mem_ctx, &rok)) {
|
||||
fprintf(stderr, "Could not open key %s. Error %s\n", rok.in.name, nt_errstr(hnd->status));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
struct RegGetKeySecurity rks;
|
||||
ZERO_STRUCT(rks);
|
||||
|
||||
rks.in.key = rok.out.key;
|
||||
rks.in.info_type = ALL_SECURITY_INFORMATION;
|
||||
|
||||
if(!cac_RegGetKeySecurity(hnd, mem_ctx, &rks)) {
|
||||
fprintf(stderr, "Could not query security for %s. Error: %s\n", rok.in.name, nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
printf("resetting key security...\n");
|
||||
|
||||
struct RegSetKeySecurity rss;
|
||||
ZERO_STRUCT(rss);
|
||||
|
||||
rss.in.key = rok.out.key;
|
||||
rss.in.info_type = ALL_SECURITY_INFORMATION;
|
||||
rss.in.size = rks.out.size;
|
||||
rss.in.descriptor = rks.out.descriptor;
|
||||
|
||||
if(!cac_RegSetKeySecurity(hnd, mem_ctx, &rss)) {
|
||||
fprintf(stderr, "Could not set security. Error %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
|
||||
done:
|
||||
cac_RegClose(hnd, mem_ctx, rok.out.key);
|
||||
|
||||
cac_FreeHandle(hnd);
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,68 +0,0 @@
|
||||
/*tries to shut down a remote pc*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
#include "test_util.h"
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
fstring tmp;
|
||||
|
||||
mem_ctx = talloc_init("cac_shutdown");
|
||||
|
||||
hnd = cac_NewServerHandle(True);
|
||||
|
||||
cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);
|
||||
|
||||
cac_parse_cmd_line(argc, argv, hnd);
|
||||
|
||||
hnd->_internal.srv_level = SRV_WIN_NT4;
|
||||
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
struct Shutdown s;
|
||||
ZERO_STRUCT(s);
|
||||
|
||||
printf("Message: ");
|
||||
cactest_readline(stdin, tmp);
|
||||
|
||||
s.in.message = talloc_strdup(mem_ctx, tmp);
|
||||
|
||||
printf("timeout: ");
|
||||
scanf("%d", &s.in.timeout);
|
||||
|
||||
printf("Reboot? [y/n]: ");
|
||||
cactest_readline(stdin, tmp);
|
||||
|
||||
s.in.reboot = ( tmp[0] == 'y') ? True : False;
|
||||
|
||||
printf("Force? [y/n]: ");
|
||||
cactest_readline(stdin, tmp);
|
||||
|
||||
s.in.force = (tmp[0] == 'y') ? True : False;
|
||||
|
||||
if(!cac_Shutdown(hnd, mem_ctx, &s)) {
|
||||
fprintf(stderr, "could not shut down server: error %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
printf("Server %s is shutting down. Would you like to try to abort? [y/n]: ", hnd->server);
|
||||
fscanf(stdin, "%s", tmp);
|
||||
|
||||
if(tmp[0] == 'y') {
|
||||
if(!cac_AbortShutdown(hnd, mem_ctx)) {
|
||||
fprintf(stderr, "Could not abort shutdown. Error %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
cac_FreeHandle(hnd);
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
/*add's a user to a domain*/
|
||||
#include "libmsrpc.h"
|
||||
#include "test_util.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
fstring tmp;
|
||||
|
||||
struct SamOpenUser ou;
|
||||
|
||||
POLICY_HND *user_hnd = NULL;
|
||||
|
||||
mem_ctx = talloc_init("cac_adduser");
|
||||
|
||||
hnd = cac_NewServerHandle(True);
|
||||
|
||||
cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);
|
||||
|
||||
cac_parse_cmd_line(argc, argv, hnd);
|
||||
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
struct SamOpenDomain sod;
|
||||
ZERO_STRUCT(sod);
|
||||
|
||||
sod.in.access = MAXIMUM_ALLOWED_ACCESS;
|
||||
|
||||
if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) {
|
||||
fprintf(stderr, "Could not open domain. Error: %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
struct SamCreateUser cdu;
|
||||
ZERO_STRUCT(cdu);
|
||||
|
||||
printf("Enter account name: ");
|
||||
cactest_readline(stdin, tmp);
|
||||
|
||||
cdu.in.dom_hnd = sod.out.dom_hnd;
|
||||
cdu.in.name = talloc_strdup(mem_ctx, tmp);
|
||||
cdu.in.acb_mask = ACB_NORMAL;
|
||||
|
||||
if(!cac_SamCreateUser(hnd, mem_ctx, &cdu)) {
|
||||
fprintf(stderr, "Could not create user %s. Error: %s\n", cdu.in.name, nt_errstr(hnd->status));
|
||||
}
|
||||
|
||||
printf("would you like to delete this user? [y/n]: ");
|
||||
cactest_readline(stdin, tmp);
|
||||
|
||||
if(tmp[0] == 'y') {
|
||||
|
||||
if(!cdu.out.user_hnd) {
|
||||
ZERO_STRUCT(ou);
|
||||
ou.in.dom_hnd = sod.out.dom_hnd;
|
||||
ou.in.access = MAXIMUM_ALLOWED_ACCESS;
|
||||
ou.in.name = talloc_strdup(mem_ctx, cdu.in.name);
|
||||
|
||||
if(!cac_SamOpenUser(hnd, mem_ctx, &ou)) {
|
||||
fprintf(stderr, "Could not open user for deletion. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
|
||||
user_hnd = ou.out.user_hnd;
|
||||
}
|
||||
|
||||
else {
|
||||
user_hnd = cdu.out.user_hnd;
|
||||
}
|
||||
|
||||
if(!cac_SamDeleteUser(hnd, mem_ctx, user_hnd))
|
||||
fprintf(stderr, "Could not delete user. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
printf("Nope..ok\n");
|
||||
}
|
||||
|
||||
cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd);
|
||||
cac_SamClose(hnd, mem_ctx, sod.out.sam);
|
||||
|
||||
done:
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
cac_FreeHandle(hnd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*TODO: add a function that will create a user and set userinfo and set the password*/
|
@ -1,63 +0,0 @@
|
||||
/*disable a user*/
|
||||
#include "libmsrpc.h"
|
||||
#include "test_util.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
struct SamOpenUser ou;
|
||||
|
||||
fstring tmp;
|
||||
|
||||
mem_ctx = talloc_init("cac_disable");
|
||||
|
||||
hnd = cac_NewServerHandle(True);
|
||||
|
||||
cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);
|
||||
|
||||
cac_parse_cmd_line(argc, argv, hnd);
|
||||
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
struct SamOpenDomain sod;
|
||||
ZERO_STRUCT(sod);
|
||||
|
||||
sod.in.access = MAXIMUM_ALLOWED_ACCESS;
|
||||
|
||||
if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) {
|
||||
fprintf(stderr, "Could not open domain. Error: %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(ou);
|
||||
printf("Enter username: ");
|
||||
cactest_readline(stdin, tmp);
|
||||
|
||||
ou.in.name = talloc_strdup(mem_ctx, tmp);
|
||||
ou.in.access = MAXIMUM_ALLOWED_ACCESS;
|
||||
ou.in.dom_hnd = sod.out.dom_hnd;
|
||||
|
||||
if(!cac_SamOpenUser(hnd, mem_ctx, &ou)) {
|
||||
fprintf(stderr, "Could not open user. Error: %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*enable the user*/
|
||||
if(!cac_SamDisableUser(hnd, mem_ctx, ou.out.user_hnd)) {
|
||||
fprintf(stderr, "Could not disable user: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
|
||||
done:
|
||||
cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd);
|
||||
|
||||
cac_FreeHandle(hnd);
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,55 +0,0 @@
|
||||
/*gets domain info and prints it out*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
#include "test_util.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
mem_ctx = talloc_init("cac_dominfo");
|
||||
|
||||
hnd = cac_NewServerHandle(True);
|
||||
|
||||
cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);
|
||||
|
||||
cac_parse_cmd_line(argc, argv, hnd);
|
||||
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
struct SamOpenDomain sod;
|
||||
ZERO_STRUCT(sod);
|
||||
|
||||
sod.in.access = MAXIMUM_ALLOWED_ACCESS;
|
||||
|
||||
if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) {
|
||||
fprintf(stderr, "Could not open domain. Error: %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
struct SamGetDomainInfo gdi;
|
||||
ZERO_STRUCT(gdi);
|
||||
|
||||
gdi.in.dom_hnd = sod.out.dom_hnd;
|
||||
|
||||
if(!cac_SamGetDomainInfo(hnd, mem_ctx, &gdi)) {
|
||||
fprintf(stderr, "Could not get domain info. Error: %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
printf("Got domain info:\n");
|
||||
print_cac_domain_info(gdi.out.info);
|
||||
|
||||
done:
|
||||
cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd);
|
||||
|
||||
cac_FreeHandle(hnd);
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,64 +0,0 @@
|
||||
/*enable a user*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
#include "test_util.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
struct SamOpenUser ou;
|
||||
|
||||
fstring tmp;
|
||||
|
||||
mem_ctx = talloc_init("cac_samgroup");
|
||||
|
||||
hnd = cac_NewServerHandle(True);
|
||||
|
||||
cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);
|
||||
|
||||
cac_parse_cmd_line(argc, argv, hnd);
|
||||
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
struct SamOpenDomain sod;
|
||||
ZERO_STRUCT(sod);
|
||||
|
||||
sod.in.access = MAXIMUM_ALLOWED_ACCESS;
|
||||
|
||||
if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) {
|
||||
fprintf(stderr, "Could not open domain. Error: %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(ou);
|
||||
printf("Enter username: ");
|
||||
cactest_readline(stdin, tmp);
|
||||
|
||||
ou.in.name = talloc_strdup(mem_ctx, tmp);
|
||||
ou.in.access = MAXIMUM_ALLOWED_ACCESS;
|
||||
ou.in.dom_hnd = sod.out.dom_hnd;
|
||||
|
||||
if(!cac_SamOpenUser(hnd, mem_ctx, &ou)) {
|
||||
fprintf(stderr, "Could not open user. Error: %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*enable the user*/
|
||||
if(!cac_SamEnableUser(hnd, mem_ctx, ou.out.user_hnd)) {
|
||||
fprintf(stderr, "Could not enable user: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
|
||||
done:
|
||||
cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd);
|
||||
|
||||
cac_FreeHandle(hnd);
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,117 +0,0 @@
|
||||
/*enumerate users/groups/aliases*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
#include "test_util.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
|
||||
struct SamEnumUsers eu;
|
||||
struct SamEnumGroups eg;
|
||||
struct SamEnumAliases ea;
|
||||
|
||||
fstring tmp;
|
||||
|
||||
int i;
|
||||
|
||||
mem_ctx = talloc_init("cac_samenum");
|
||||
|
||||
hnd = cac_NewServerHandle(True);
|
||||
|
||||
cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);
|
||||
|
||||
cac_parse_cmd_line(argc, argv, hnd);
|
||||
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
struct SamOpenDomain sod;
|
||||
ZERO_STRUCT(sod);
|
||||
|
||||
sod.in.access = MAXIMUM_ALLOWED_ACCESS;
|
||||
|
||||
if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) {
|
||||
fprintf(stderr, "Could not open domain. Error: %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
tmp[0] = 0x00;
|
||||
while(tmp[0] != 'q') {
|
||||
printf("Enumerate [u]sers, [g]roups or [a]liases or [q]uit: ");
|
||||
cactest_readline(stdin, tmp);
|
||||
|
||||
switch(tmp[0]) {
|
||||
case 'u':
|
||||
ZERO_STRUCT(eu);
|
||||
|
||||
eu.in.dom_hnd = sod.out.dom_hnd;
|
||||
|
||||
printf("ACB mask (can be 0): ");
|
||||
scanf("%x", &eu.in.acb_mask);
|
||||
|
||||
while(cac_SamEnumUsers(hnd, mem_ctx, &eu)) {
|
||||
printf("Enumerated %d users:\n", eu.out.num_users);
|
||||
for(i = 0; i < eu.out.num_users; i++) {
|
||||
printf(" Name: %s\n", eu.out.names[i]);
|
||||
printf(" RID: %d\n", eu.out.rids[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if(CAC_OP_FAILED(hnd->status)) {
|
||||
printf("Could not enumerate users. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
break;
|
||||
case 'g':
|
||||
ZERO_STRUCT(eg);
|
||||
eg.in.dom_hnd = sod.out.dom_hnd;
|
||||
|
||||
printf("Enumerating groups...\n");
|
||||
while(cac_SamEnumGroups(hnd, mem_ctx, &eg)) {
|
||||
printf("Enumerated %d groups:\n", eg.out.num_groups);
|
||||
for(i = 0; i < eg.out.num_groups; i++) {
|
||||
printf("RID: %d\n", eg.out.rids[i]);
|
||||
printf("Name: %s\n", eg.out.names[i]);
|
||||
printf("Desc: %s\n", eg.out.descriptions[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if(CAC_OP_FAILED(hnd->status)) {
|
||||
printf("Could not enumerate Groups. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
break;
|
||||
case 'a':
|
||||
ZERO_STRUCT(ea);
|
||||
ea.in.dom_hnd = sod.out.dom_hnd;
|
||||
|
||||
printf("Enumerating Aliases...\n");
|
||||
while(cac_SamEnumAliases(hnd, mem_ctx, &ea)) {
|
||||
printf("Enumerated %d aliases:\n", ea.out.num_aliases);
|
||||
|
||||
for(i = 0; i < ea.out.num_aliases; i++) {
|
||||
printf("RID: %d\n", ea.out.rids[i]);
|
||||
printf("Name: %s\n", ea.out.names[i]);
|
||||
printf("Desc: %s\n", ea.out.descriptions[i]);
|
||||
}
|
||||
}
|
||||
if(CAC_OP_FAILED(hnd->status)) {
|
||||
printf("Could not enumerate Aliases. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd);
|
||||
cac_SamClose(hnd, mem_ctx, sod.out.sam);
|
||||
|
||||
done:
|
||||
talloc_destroy(mem_ctx);
|
||||
cac_FreeHandle(hnd);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
@ -1,480 +0,0 @@
|
||||
/*Some group management stuff*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
#include "test_util.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
|
||||
struct SamEnumGroups eg;
|
||||
struct SamEnumUsers eu;
|
||||
struct SamCreateGroup cg;
|
||||
struct SamOpenGroup og;
|
||||
struct SamGetGroupMembers ggm;
|
||||
struct SamGetNamesFromRids gn;
|
||||
struct SamAddGroupMember add;
|
||||
struct SamRemoveGroupMember del;
|
||||
struct SamSetGroupMembers set;
|
||||
struct SamGetGroupsForUser gg;
|
||||
struct SamOpenUser ou;
|
||||
struct SamGetGroupInfo gi;
|
||||
struct SamSetGroupInfo si;
|
||||
struct SamRenameGroup rg;
|
||||
struct SamGetSecurityObject gso;
|
||||
|
||||
POLICY_HND *group_hnd = NULL;
|
||||
|
||||
fstring tmp;
|
||||
fstring input;
|
||||
|
||||
int i;
|
||||
|
||||
mem_ctx = talloc_init("cac_samgroup");
|
||||
|
||||
hnd = cac_NewServerHandle(True);
|
||||
|
||||
cac_parse_cmd_line(argc, argv, hnd);
|
||||
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
struct SamOpenDomain sod;
|
||||
ZERO_STRUCT(sod);
|
||||
|
||||
sod.in.access = MAXIMUM_ALLOWED_ACCESS;
|
||||
|
||||
if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) {
|
||||
fprintf(stderr, "Could not open domain. Error: %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
tmp[0] = 0x00;
|
||||
while(tmp[0] != 'q') {
|
||||
printf("\n");
|
||||
printf("[l]ist groups\n");
|
||||
printf("[c]reate group\n");
|
||||
printf("[o]pen group\n");
|
||||
printf("[d]elete group\n");
|
||||
printf("list [m]embers\n");
|
||||
printf("list [u]sers\n");
|
||||
printf("list [g]roup for users\n");
|
||||
printf("[a]dd member\n");
|
||||
printf("[r]emove member\n");
|
||||
printf("[x] clear members\n");
|
||||
printf("get group [i]nfo\n");
|
||||
printf("[e]dit group info\n");
|
||||
printf("[s]et members\n");
|
||||
printf("re[n]ame group\n");
|
||||
printf("[z] close group\n");
|
||||
printf("[t] get security info\n");
|
||||
|
||||
printf("[q]uit\n\n");
|
||||
printf("Enter option: ");
|
||||
cactest_readline(stdin, tmp);
|
||||
|
||||
printf("\n");
|
||||
|
||||
switch(tmp[0]) {
|
||||
case 'c': /*create group*/
|
||||
if(group_hnd != NULL) {
|
||||
/*then we have an open handle.. close it*/
|
||||
cac_SamClose(hnd, mem_ctx, group_hnd);
|
||||
group_hnd = NULL;
|
||||
}
|
||||
|
||||
printf("Enter group name: ");
|
||||
cactest_readline(stdin, input);
|
||||
|
||||
ZERO_STRUCT(cg);
|
||||
|
||||
cg.in.name = talloc_strdup(mem_ctx, input);
|
||||
cg.in.access = MAXIMUM_ALLOWED_ACCESS;
|
||||
cg.in.dom_hnd = sod.out.dom_hnd;
|
||||
|
||||
if(!cac_SamCreateGroup(hnd, mem_ctx, &cg)) {
|
||||
fprintf(stderr, "Could not create group. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
printf("Created group %s\n", cg.in.name);
|
||||
|
||||
group_hnd = cg.out.group_hnd;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'o': /*open group*/
|
||||
if(group_hnd != NULL) {
|
||||
/*then we have an open handle.. close it*/
|
||||
cac_SamClose(hnd, mem_ctx, group_hnd);
|
||||
group_hnd = NULL;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(og);
|
||||
|
||||
og.in.dom_hnd = sod.out.dom_hnd;
|
||||
og.in.access = MAXIMUM_ALLOWED_ACCESS;
|
||||
|
||||
printf("Enter RID: 0x");
|
||||
scanf("%x", &og.in.rid);
|
||||
|
||||
if(!cac_SamOpenGroup(hnd, mem_ctx, &og)) {
|
||||
fprintf(stderr, "Could not open group. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
printf("Opened group\n");
|
||||
group_hnd = og.out.group_hnd;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'l': /*list groups*/
|
||||
ZERO_STRUCT(eg);
|
||||
eg.in.dom_hnd = sod.out.dom_hnd;
|
||||
|
||||
while(cac_SamEnumGroups(hnd, mem_ctx, &eg)) {
|
||||
for(i = 0; i < eg.out.num_groups; i++) {
|
||||
printf("RID: 0x%x Name: %s\n", eg.out.rids[i], eg.out.names[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if(CAC_OP_FAILED(hnd->status)) {
|
||||
printf("Could not enumerate Groups. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'm': /*list group members*/
|
||||
if(!group_hnd) {
|
||||
printf("Must open group first!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(ggm);
|
||||
ggm.in.group_hnd = group_hnd;
|
||||
|
||||
if(!cac_SamGetGroupMembers(hnd, mem_ctx, &ggm)) {
|
||||
fprintf(stderr, "Could not get group members. Error: %s\n", nt_errstr(hnd->status));
|
||||
break;
|
||||
}
|
||||
|
||||
printf("Group has %d members:\n", ggm.out.num_members);
|
||||
|
||||
if(ggm.out.num_members == 0) /*just skip the rest of this case*/
|
||||
break;
|
||||
|
||||
/**get the user names*/
|
||||
gn.in.dom_hnd = sod.out.dom_hnd;
|
||||
gn.in.num_rids = ggm.out.num_members;
|
||||
gn.in.rids = ggm.out.rids;
|
||||
|
||||
if(!cac_SamGetNamesFromRids(hnd, mem_ctx, &gn)) {
|
||||
fprintf(stderr, "Could not lookup names. Error: %s\n", nt_errstr(hnd->status));
|
||||
break;
|
||||
}
|
||||
|
||||
for(i = 0; i < gn.out.num_names; i++) {
|
||||
printf("RID: 0x%x Name: %s\n", gn.out.map[i].rid, gn.out.map[i].name);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'd': /*delete group*/
|
||||
if(!group_hnd) {
|
||||
printf("Must open group first!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if(!cac_SamDeleteGroup(hnd, mem_ctx, group_hnd)) {
|
||||
fprintf(stderr, "Could not delete group. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
printf("Deleted group.\n");
|
||||
group_hnd = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'u': /*list users*/
|
||||
ZERO_STRUCT(eu);
|
||||
|
||||
eu.in.dom_hnd = sod.out.dom_hnd;
|
||||
|
||||
while(cac_SamEnumUsers(hnd, mem_ctx, &eu)) {
|
||||
for(i = 0; i < eu.out.num_users; i++) {
|
||||
printf(" RID: 0x%x Name: %s\n", eu.out.rids[i], eu.out.names[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if(CAC_OP_FAILED(hnd->status)) {
|
||||
printf("Could not enumerate users. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'a': /*add member to group*/
|
||||
if(!group_hnd) {
|
||||
printf("Must open group first!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(add);
|
||||
|
||||
add.in.group_hnd = group_hnd;
|
||||
|
||||
printf("Enter user RID: 0x");
|
||||
scanf("%x", &add.in.rid);
|
||||
|
||||
if(!cac_SamAddGroupMember(hnd, mem_ctx, &add)) {
|
||||
fprintf(stderr, "Could not add user to group. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
printf("Successfully added user to group\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case 'r': /*remove user from group*/
|
||||
if(!group_hnd) {
|
||||
printf("Must open group first!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(del);
|
||||
del.in.group_hnd = group_hnd;
|
||||
|
||||
printf("Enter RID: 0x");
|
||||
scanf("%x", &del.in.rid);
|
||||
|
||||
if(!cac_SamRemoveGroupMember(hnd, mem_ctx, &del)) {
|
||||
fprintf(stderr, "Could not remove user from group. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
printf("Removed user from group.\n");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'x': /*clear group members*/
|
||||
if(!group_hnd) {
|
||||
printf("Must open group first!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if(!cac_SamClearGroupMembers(hnd, mem_ctx, group_hnd)) {
|
||||
fprintf(stderr, "Could not clear group members. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
printf("Cleared group members\n");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 's': /*set members*/
|
||||
if(!group_hnd) {
|
||||
printf("Must open group first!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(set);
|
||||
|
||||
set.in.group_hnd = group_hnd;
|
||||
|
||||
printf("Enter the number of members: ");
|
||||
scanf("%d", &set.in.num_members);
|
||||
|
||||
set.in.rids = TALLOC_ARRAY(mem_ctx, uint32, set.in.num_members);
|
||||
|
||||
for(i = 0; i < set.in.num_members; i++) {
|
||||
printf("Enter RID #%d: 0x", (i+1));
|
||||
scanf("%x", (set.in.rids + i));
|
||||
}
|
||||
|
||||
if(!cac_SamSetGroupMembers(hnd, mem_ctx, &set)) {
|
||||
printf("could not set members. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
printf("Set users\n");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'g': /*list groups for user*/
|
||||
ZERO_STRUCT(ou);
|
||||
ZERO_STRUCT(gg);
|
||||
|
||||
printf("Enter username: ");
|
||||
cactest_readline(stdin, input);
|
||||
|
||||
if(input[0] != '\0') {
|
||||
ou.in.name = talloc_strdup(mem_ctx, input);
|
||||
}
|
||||
else {
|
||||
printf("Enter RID: 0x");
|
||||
scanf("%x", &ou.in.rid);
|
||||
}
|
||||
|
||||
ou.in.access = MAXIMUM_ALLOWED_ACCESS;
|
||||
ou.in.dom_hnd = sod.out.dom_hnd;
|
||||
|
||||
if(!cac_SamOpenUser(hnd, mem_ctx, &ou)) {
|
||||
fprintf(stderr, "Could not open user %s. Error: %s\n", ou.in.name, nt_errstr(hnd->status));
|
||||
break;
|
||||
}
|
||||
|
||||
/*now find the groups*/
|
||||
gg.in.user_hnd = ou.out.user_hnd;
|
||||
|
||||
if(!cac_SamGetGroupsForUser(hnd, mem_ctx, &gg)) {
|
||||
fprintf(stderr, "Could not get groups for user. Error: %s\n", nt_errstr(hnd->status));
|
||||
break;
|
||||
}
|
||||
|
||||
cac_SamClose(hnd, mem_ctx, ou.out.user_hnd);
|
||||
|
||||
ZERO_STRUCT(gn);
|
||||
|
||||
gn.in.dom_hnd = sod.out.dom_hnd;
|
||||
gn.in.num_rids = gg.out.num_groups;
|
||||
gn.in.rids = gg.out.rids;
|
||||
|
||||
if(!cac_SamGetNamesFromRids(hnd, mem_ctx, &gn)) {
|
||||
fprintf(stderr, "Could not get names from RIDs. Error: %s\n", nt_errstr(hnd->status));
|
||||
break;
|
||||
}
|
||||
|
||||
printf("%d groups: \n", gn.out.num_names);
|
||||
|
||||
for(i = 0; i < gn.out.num_names; i++) {
|
||||
printf("RID: 0x%x ", gn.out.map[i].rid);
|
||||
|
||||
if(gn.out.map[i].found)
|
||||
printf("Name: %s\n", gn.out.map[i].name);
|
||||
else
|
||||
printf("Unknown RID\n");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'z': /*close group*/
|
||||
if(!group_hnd) {
|
||||
printf("Must open group first!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if(!cac_SamClose(hnd, mem_ctx, group_hnd)) {
|
||||
printf("Could not close group\n");
|
||||
break;
|
||||
}
|
||||
|
||||
group_hnd = NULL;
|
||||
break;
|
||||
|
||||
case 'i': /*get group info*/
|
||||
if(!group_hnd) {
|
||||
printf("Must open group first!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(gi);
|
||||
gi.in.group_hnd = group_hnd;
|
||||
|
||||
if(!cac_SamGetGroupInfo(hnd, mem_ctx, &gi)) {
|
||||
printf("Could not get group info. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
printf("Retrieved Group info\n");
|
||||
print_cac_group_info(gi.out.info);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'e': /*edit group info*/
|
||||
if(!group_hnd) {
|
||||
printf("Must open group first!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(gi);
|
||||
ZERO_STRUCT(si);
|
||||
|
||||
gi.in.group_hnd = group_hnd;
|
||||
|
||||
if(!cac_SamGetGroupInfo(hnd, mem_ctx, &gi)) {
|
||||
printf("Could not get group info. Error: %s\n", nt_errstr(hnd->status));
|
||||
break;
|
||||
}
|
||||
|
||||
edit_cac_group_info(mem_ctx, gi.out.info);
|
||||
|
||||
si.in.group_hnd = group_hnd;
|
||||
si.in.info = gi.out.info;
|
||||
|
||||
if(!cac_SamSetGroupInfo(hnd, mem_ctx, &si)) {
|
||||
printf("Could not set group info. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
printf(" Done.\n");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'n': /*rename group*/
|
||||
if(!group_hnd) {
|
||||
printf("Must open group first!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(rg);
|
||||
|
||||
printf("Enter new group name: ");
|
||||
cactest_readline(stdin, tmp);
|
||||
|
||||
rg.in.group_hnd = group_hnd;
|
||||
rg.in.new_name = talloc_strdup(mem_ctx, tmp);
|
||||
|
||||
if(!cac_SamRenameGroup(hnd, mem_ctx, &rg))
|
||||
printf("Could not rename group. Error: %s\n", nt_errstr(hnd->status));
|
||||
else
|
||||
printf("Done.\n");
|
||||
|
||||
break;
|
||||
case 't': /*get security info*/
|
||||
if(!group_hnd) {
|
||||
printf("Must open group first!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(gso);
|
||||
|
||||
gso.in.pol = group_hnd;
|
||||
|
||||
if(!cac_SamGetSecurityObject(hnd, mem_ctx, &gso)) {
|
||||
printf("Could not get security descriptor info. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
printf("Got it.\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Invalid command\n");
|
||||
}
|
||||
}
|
||||
|
||||
cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd);
|
||||
|
||||
if(group_hnd)
|
||||
cac_SamClose(hnd, mem_ctx, group_hnd);
|
||||
|
||||
done:
|
||||
cac_FreeHandle(hnd);
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,140 +0,0 @@
|
||||
/*lookup names or rids*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
#include "test_util.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
|
||||
struct SamGetNamesFromRids sgn;
|
||||
struct SamGetRidsFromNames sgr;
|
||||
|
||||
fstring tmp;
|
||||
fstring input;
|
||||
|
||||
int i;
|
||||
|
||||
mem_ctx = talloc_init("cac_samenum");
|
||||
|
||||
hnd = cac_NewServerHandle(True);
|
||||
|
||||
cac_parse_cmd_line(argc, argv, hnd);
|
||||
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
struct SamOpenDomain sod;
|
||||
ZERO_STRUCT(sod);
|
||||
|
||||
sod.in.access = MAXIMUM_ALLOWED_ACCESS;
|
||||
|
||||
if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) {
|
||||
fprintf(stderr, "Could not open domain. Error: %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
tmp[0] = 0x00;
|
||||
while(tmp[0] != 'q') {
|
||||
printf("get [n]ames or get [r]ids or [q]uit: ");
|
||||
cactest_readline(stdin, tmp);
|
||||
|
||||
switch(tmp[0]) {
|
||||
case 'n':
|
||||
ZERO_STRUCT(sgn);
|
||||
|
||||
sgn.in.dom_hnd = sod.out.dom_hnd;
|
||||
|
||||
printf("How many rids will you enter: ");
|
||||
scanf("%d", &sgn.in.num_rids);
|
||||
|
||||
sgn.in.rids = talloc_array(mem_ctx, int, sgn.in.num_rids);
|
||||
|
||||
for(i = 0; i < sgn.in.num_rids; i++) {
|
||||
printf(" Enter RID %d: 0x", i);
|
||||
scanf("%x", &sgn.in.rids[i]);
|
||||
}
|
||||
|
||||
printf("Getting names...\n");
|
||||
|
||||
if(!cac_SamGetNamesFromRids(hnd, mem_ctx, &sgn)) {
|
||||
fprintf(stderr, "could not lookup names. Error: %s\n", nt_errstr(hnd->status));
|
||||
talloc_free(sgn.in.rids);
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("Found %d names:\n", sgn.out.num_names);
|
||||
|
||||
for(i = 0; i < sgn.out.num_names; i++) {
|
||||
printf(" RID: 0x%x ", sgn.out.map[i].rid);
|
||||
|
||||
if(sgn.out.map[i].found) {
|
||||
printf("Name: %s\n", sgn.out.map[i].name);
|
||||
}
|
||||
else {
|
||||
printf("Unknown RID\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
ZERO_STRUCT(sgr);
|
||||
|
||||
sgr.in.dom_hnd = sod.out.dom_hnd;
|
||||
|
||||
printf("How many names will you enter: ");
|
||||
scanf("%d", &sgr.in.num_names);
|
||||
|
||||
sgr.in.names = talloc_array(mem_ctx, char *, sgr.in.num_names);
|
||||
|
||||
for(i = 0; i < sgr.in.num_names; i++) {
|
||||
printf(" Enter name %d: ", (i+1));
|
||||
cactest_readline(stdin, input);
|
||||
|
||||
sgr.in.names[i] = talloc_strdup(mem_ctx, input);
|
||||
}
|
||||
|
||||
if(!cac_SamGetRidsFromNames(hnd, mem_ctx, &sgr)) {
|
||||
fprintf(stderr, "Could not lookup names. Error: %s\n", nt_errstr(hnd->status));
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("Found %d RIDs:\n", sgr.out.num_rids);
|
||||
|
||||
for(i = 0; i < sgr.out.num_rids; i++) {
|
||||
printf(" Name: %s ", sgr.out.map[i].name);
|
||||
|
||||
if(sgr.out.map[i].found) {
|
||||
printf("RID: 0x%x\n", sgr.out.map[i].rid);
|
||||
}
|
||||
else {
|
||||
printf("Unknown name\n");
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'q':
|
||||
printf("\n");
|
||||
break;
|
||||
default:
|
||||
printf("Invalid command!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd);
|
||||
cac_SamClose(hnd, mem_ctx, sod.out.sam);
|
||||
|
||||
done:
|
||||
talloc_destroy(mem_ctx);
|
||||
cac_FreeHandle(hnd);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
@ -1,294 +0,0 @@
|
||||
/*Some user management stuff*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
#include "test_util.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
|
||||
struct SamOpenUser ou;
|
||||
struct SamEnumUsers eu;
|
||||
struct SamCreateUser cu;
|
||||
struct SamGetUserInfo gi;
|
||||
struct SamSetUserInfo si;
|
||||
struct SamRenameUser ru;
|
||||
struct SamSetPassword sp;
|
||||
|
||||
POLICY_HND *user_hnd = NULL;
|
||||
|
||||
fstring tmp;
|
||||
fstring input;
|
||||
|
||||
char *pass1 = NULL;
|
||||
char *pass2 = NULL;
|
||||
|
||||
int i;
|
||||
|
||||
mem_ctx = talloc_init("cac_samgroup");
|
||||
|
||||
hnd = cac_NewServerHandle(True);
|
||||
|
||||
cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);
|
||||
|
||||
cac_parse_cmd_line(argc, argv, hnd);
|
||||
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
struct SamOpenDomain sod;
|
||||
ZERO_STRUCT(sod);
|
||||
|
||||
sod.in.access = MAXIMUM_ALLOWED_ACCESS;
|
||||
|
||||
if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) {
|
||||
fprintf(stderr, "Could not open domain. Error: %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
tmp[0] = 0x00;
|
||||
while(tmp[0] != 'q') {
|
||||
printf("\n");
|
||||
printf("[l]ist users\n");
|
||||
printf("[c]reate user\n");
|
||||
printf("[o]pen user\n");
|
||||
printf("[d]elete user\n");
|
||||
printf("[g]et user info\n");
|
||||
printf("[e]dit user info\n");
|
||||
printf("[r]ename user\n");
|
||||
printf("reset [p]assword\n");
|
||||
printf("[n] close user\n");
|
||||
|
||||
printf("[q]uit\n\n");
|
||||
printf("Enter option: ");
|
||||
cactest_readline(stdin, tmp);
|
||||
|
||||
printf("\n");
|
||||
|
||||
switch(tmp[0]) {
|
||||
case 'c': /*create user*/
|
||||
if(user_hnd != NULL) {
|
||||
/*then we have an open handle.. close it*/
|
||||
cac_SamClose(hnd, mem_ctx, user_hnd);
|
||||
user_hnd = NULL;
|
||||
}
|
||||
|
||||
printf("Enter user name: ");
|
||||
cactest_readline(stdin, input);
|
||||
|
||||
ZERO_STRUCT(cu);
|
||||
|
||||
cu.in.name = talloc_strdup(mem_ctx, input);
|
||||
cu.in.dom_hnd = sod.out.dom_hnd;
|
||||
cu.in.acb_mask = ACB_NORMAL;
|
||||
|
||||
if(!cac_SamCreateUser(hnd, mem_ctx, &cu)) {
|
||||
printf("Could not create user. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
printf("Created user %s with RID 0x%x\n", cu.in.name, cu.out.rid);
|
||||
user_hnd = cu.out.user_hnd;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'o': /*open group*/
|
||||
if(user_hnd != NULL) {
|
||||
/*then we have an open handle.. close it*/
|
||||
cac_SamClose(hnd, mem_ctx, user_hnd);
|
||||
user_hnd = NULL;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(ou);
|
||||
|
||||
ou.in.dom_hnd = sod.out.dom_hnd;
|
||||
ou.in.access = MAXIMUM_ALLOWED_ACCESS;
|
||||
|
||||
printf("Enter RID: 0x");
|
||||
scanf("%x", &ou.in.rid);
|
||||
|
||||
if(!cac_SamOpenUser(hnd, mem_ctx, &ou)) {
|
||||
fprintf(stderr, "Could not open user. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
printf("Opened user\n");
|
||||
user_hnd = ou.out.user_hnd;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'l': /*list users*/
|
||||
ZERO_STRUCT(eu);
|
||||
eu.in.dom_hnd = sod.out.dom_hnd;
|
||||
|
||||
while(cac_SamEnumUsers(hnd, mem_ctx, &eu)) {
|
||||
for(i = 0; i < eu.out.num_users; i++) {
|
||||
printf("RID: 0x%x Name: %s\n", eu.out.rids[i], eu.out.names[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if(CAC_OP_FAILED(hnd->status)) {
|
||||
printf("Could not enumerate Users. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
break;
|
||||
|
||||
case 'd': /*delete group*/
|
||||
if(!user_hnd) {
|
||||
printf("Must open group first!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if(!cac_SamDeleteGroup(hnd, mem_ctx, user_hnd)) {
|
||||
fprintf(stderr, "Could not delete group. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
printf("Deleted group.\n");
|
||||
user_hnd = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'n':
|
||||
if(!user_hnd) {
|
||||
printf("Must open user first!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if(!cac_SamClose(hnd, mem_ctx, user_hnd)) {
|
||||
printf("Could not user group\n");
|
||||
break;
|
||||
}
|
||||
|
||||
user_hnd = NULL;
|
||||
break;
|
||||
|
||||
case 'g': /*get user info*/
|
||||
if(!user_hnd) {
|
||||
printf("Must open user first!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(gi);
|
||||
gi.in.user_hnd = ou.out.user_hnd;
|
||||
|
||||
if(!cac_SamGetUserInfo(hnd, mem_ctx, &gi)) {
|
||||
printf("Could not get user info. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
printf("Retrieved User information:\n");
|
||||
print_cac_user_info(gi.out.info);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'e': /*edit user info*/
|
||||
if(!user_hnd) {
|
||||
printf("Must Open user first!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(gi);
|
||||
gi.in.user_hnd = ou.out.user_hnd;
|
||||
if(!cac_SamGetUserInfo(hnd, mem_ctx, &gi)) {
|
||||
printf("Could not get user info. Error: %s\n", nt_errstr(hnd->status));
|
||||
break;
|
||||
}
|
||||
|
||||
edit_cac_user_info(mem_ctx, gi.out.info);
|
||||
|
||||
printf("setting following info:\n");
|
||||
print_cac_user_info(gi.out.info);
|
||||
|
||||
ZERO_STRUCT(si);
|
||||
|
||||
si.in.user_hnd = user_hnd;
|
||||
si.in.info = gi.out.info;
|
||||
|
||||
if(!cac_SamSetUserInfo(hnd, mem_ctx, &si)) {
|
||||
printf("Could not set user info. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
printf("Done.\n");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'r': /*rename user*/
|
||||
if(!user_hnd) {
|
||||
printf("Must open user first!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(ru);
|
||||
|
||||
printf("Enter new username: ");
|
||||
cactest_readline(stdin, tmp);
|
||||
|
||||
ru.in.user_hnd = user_hnd;
|
||||
ru.in.new_name = talloc_strdup(mem_ctx, tmp);
|
||||
|
||||
if(!cac_SamRenameUser(hnd, mem_ctx, &ru)) {
|
||||
printf("Could not rename user. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
printf("Renamed user\n");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'p': /*reset password*/
|
||||
|
||||
if(!user_hnd) {
|
||||
printf("Must open user first!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
do {
|
||||
if(pass1 && pass2) {
|
||||
printf("Passwords do not match. Please try again\n");
|
||||
}
|
||||
|
||||
pass1 = getpass("Enter new password: ");
|
||||
pass2 = getpass("Re-enter new password: ");
|
||||
} while(strncmp(pass1, pass2, MAX_PASS_LEN));
|
||||
|
||||
ZERO_STRUCT(sp);
|
||||
sp.in.user_hnd = user_hnd;
|
||||
sp.in.password = talloc_strdup(mem_ctx, pass1);
|
||||
|
||||
if(!cac_SamSetPassword(hnd, mem_ctx, &sp)) {
|
||||
printf("Could not set password. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
printf("Done.\n");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Invalid command\n");
|
||||
}
|
||||
}
|
||||
|
||||
cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd);
|
||||
|
||||
if(user_hnd)
|
||||
cac_SamClose(hnd, mem_ctx, user_hnd);
|
||||
|
||||
done:
|
||||
cac_FreeHandle(hnd);
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,87 +0,0 @@
|
||||
/*simple test for libsmbclient compatibility. initialize a smbc context, open sessions on a couple pipes and quit*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
#include "libsmbclient.h"
|
||||
#include "test_util.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
SMBCCTX *ctx = NULL;
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
struct LsaOpenPolicy lop;
|
||||
struct RegConnect rc;
|
||||
struct SamOpenDomain sod;
|
||||
|
||||
ZERO_STRUCT(lop);
|
||||
ZERO_STRUCT(rc);
|
||||
ZERO_STRUCT(sod);
|
||||
|
||||
mem_ctx = talloc_init("cac_smbc");
|
||||
if(!mem_ctx) {
|
||||
printf("Could not initialize talloc context\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
hnd = cac_NewServerHandle(True);
|
||||
|
||||
cac_parse_cmd_line(argc, argv, hnd);
|
||||
|
||||
/*initialize smbc context*/
|
||||
if( (ctx = smbc_new_context()) == NULL) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*this probably isn't what someone would want to do, but it initializes the values we need*/
|
||||
ctx->debug = hnd->debug;
|
||||
ctx->callbacks.auth_fn = cac_GetAuthDataFn;
|
||||
|
||||
|
||||
if(smbc_init_context(ctx) == NULL)
|
||||
exit(1);
|
||||
|
||||
cac_SetSmbcContext(hnd, ctx);
|
||||
|
||||
/*still have to call cac_Connect()*/
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
printf("Could not connect to server\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
lop.in.access = MAXIMUM_ALLOWED_ACCESS;
|
||||
if(!cac_LsaOpenPolicy(hnd, mem_ctx, &lop))
|
||||
printf("Could not open LSA policy. Error: %s\n", nt_errstr(hnd->status));
|
||||
|
||||
printf("Opened LSA policy.\n");
|
||||
|
||||
rc.in.access = MAXIMUM_ALLOWED_ACCESS;
|
||||
rc.in.root = HKEY_LOCAL_MACHINE;
|
||||
if(!cac_RegConnect(hnd, mem_ctx, &rc))
|
||||
printf("Could not connect to registry. Error: %s\n", nt_errstr(hnd->status));
|
||||
|
||||
printf("Connceted to Registry.\n");
|
||||
|
||||
sod.in.access = MAXIMUM_ALLOWED_ACCESS;
|
||||
|
||||
if(!cac_SamOpenDomain(hnd, mem_ctx, &sod))
|
||||
printf("Could not open domain SAM. Error: %s\n", nt_errstr(hnd->status));
|
||||
|
||||
printf("Opened domain.\n");
|
||||
|
||||
if(lop.out.pol)
|
||||
cac_LsaClosePolicy(hnd, mem_ctx, lop.out.pol);
|
||||
|
||||
if(rc.out.key)
|
||||
cac_RegClose(hnd, mem_ctx, rc.out.key);
|
||||
|
||||
if(sod.out.sam)
|
||||
cac_SamClose(hnd, mem_ctx, sod.out.sam);
|
||||
|
||||
if(sod.out.dom_hnd)
|
||||
cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd);
|
||||
|
||||
cac_FreeHandle(hnd);
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,303 +0,0 @@
|
||||
/*Tests all of the svcctl calls (at least at time of writing)*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
#include "test_util.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
CacServerHandle *hnd = NULL;
|
||||
TALLOC_CTX *mem_ctx = NULL;
|
||||
|
||||
|
||||
struct SvcOpenScm sos;
|
||||
struct SvcEnumServices es;
|
||||
struct SvcOpenService os;
|
||||
struct SvcGetStatus gs;
|
||||
struct SvcStartService start;
|
||||
struct SvcStopService stop;
|
||||
struct SvcPauseService pause;
|
||||
struct SvcContinueService res;
|
||||
struct SvcGetDisplayName gdn;
|
||||
struct SvcGetServiceConfig sgc;
|
||||
|
||||
POLICY_HND *svc_hnd = NULL;
|
||||
|
||||
fstring tmp;
|
||||
fstring input;
|
||||
|
||||
int i;
|
||||
|
||||
mem_ctx = talloc_init("cac_samgroup");
|
||||
|
||||
hnd = cac_NewServerHandle(True);
|
||||
|
||||
cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);
|
||||
|
||||
cac_parse_cmd_line(argc, argv, hnd);
|
||||
|
||||
if(!cac_Connect(hnd, NULL)) {
|
||||
fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/*open a handle to the scm*/
|
||||
ZERO_STRUCT(sos);
|
||||
|
||||
sos.in.access = SC_MANAGER_ALL_ACCESS;
|
||||
|
||||
if(!cac_SvcOpenScm(hnd, mem_ctx, &sos)) {
|
||||
fprintf(stderr, "Could not open SCM. Error: %s\n", nt_errstr(hnd->status));
|
||||
goto done;
|
||||
}
|
||||
|
||||
printf("Opened SCM\n");
|
||||
|
||||
tmp[0] = 0x00;
|
||||
while(tmp[0] != 'q') {
|
||||
printf("\n");
|
||||
printf("[e] Enum Services\n");
|
||||
printf("[o] Open Service\n");
|
||||
printf("[x] Close Service\n");
|
||||
printf("[g] Get service status\n");
|
||||
printf("[s] Start service\n");
|
||||
printf("[t] Stop service\n");
|
||||
printf("[p] Pause service\n");
|
||||
printf("[r] Resume service\n");
|
||||
printf("[c] Get service config\n");
|
||||
|
||||
printf("[d] Get display name\n");
|
||||
|
||||
printf("[q]uit\n\n");
|
||||
printf("Enter option: ");
|
||||
cactest_readline(stdin, tmp);
|
||||
|
||||
printf("\n");
|
||||
|
||||
switch(tmp[0]) {
|
||||
case 'e': /*enum services*/
|
||||
ZERO_STRUCT(es);
|
||||
es.in.scm_hnd = sos.out.scm_hnd;
|
||||
|
||||
if(!cac_SvcEnumServices(hnd, mem_ctx, &es)) {
|
||||
printf("Could not enumerate services. Error: %s\n", nt_errstr(hnd->status));
|
||||
break;
|
||||
}
|
||||
|
||||
for(i = 0; i < es.out.num_services; i++) {
|
||||
print_cac_service(es.out.services[i]);
|
||||
}
|
||||
printf("Enumerated %d services:\n", es.out.num_services);
|
||||
|
||||
break;
|
||||
|
||||
case 'o': /*Open service*/
|
||||
ZERO_STRUCT(os);
|
||||
|
||||
printf("Enter service name: ");
|
||||
cactest_readline(stdin, tmp);
|
||||
|
||||
os.in.name = talloc_strdup(mem_ctx, tmp);
|
||||
os.in.scm_hnd = sos.out.scm_hnd;
|
||||
os.in.access = SERVICE_ALL_ACCESS;
|
||||
|
||||
if(!cac_SvcOpenService(hnd, mem_ctx, &os)) {
|
||||
printf("Could not open service. Error: %s\n", nt_errstr(hnd->status));
|
||||
break;
|
||||
}
|
||||
|
||||
printf("Opened service.\n");
|
||||
svc_hnd = os.out.svc_hnd;
|
||||
|
||||
break;
|
||||
case 'x': /*close service*/
|
||||
if(!svc_hnd) {
|
||||
printf("Must open service first!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
cac_SvcClose(hnd, mem_ctx, svc_hnd);
|
||||
svc_hnd = NULL;
|
||||
break;
|
||||
case 'g': /*get svc status*/
|
||||
|
||||
if(!svc_hnd) {
|
||||
printf("Must open service first!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(gs);
|
||||
|
||||
gs.in.svc_hnd = svc_hnd;
|
||||
|
||||
if(!cac_SvcGetStatus(hnd, mem_ctx, &gs)) {
|
||||
printf("Could not get status. Error: %s\n", nt_errstr(hnd->status));
|
||||
break;
|
||||
}
|
||||
|
||||
print_service_status(gs.out.status);
|
||||
break;
|
||||
case 's': /*start service*/
|
||||
if(!svc_hnd) {
|
||||
printf("Must open service first!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(start);
|
||||
|
||||
start.in.svc_hnd = svc_hnd;
|
||||
|
||||
printf("Enter number of parameters: ");
|
||||
scanf("%d", &start.in.num_parms);
|
||||
|
||||
start.in.parms = talloc_array(mem_ctx, char *, start.in.num_parms);
|
||||
|
||||
for(i = 0; i < start.in.num_parms; i++) {
|
||||
printf("Parm %d: ", i);
|
||||
cactest_readline(stdin, tmp);
|
||||
start.in.parms[i] = talloc_strdup(mem_ctx, tmp);
|
||||
}
|
||||
|
||||
printf("Timeout (seconds): ");
|
||||
scanf("%d", &start.in.timeout);
|
||||
|
||||
if(!cac_SvcStartService(hnd, mem_ctx, &start)) {
|
||||
printf("Could not start service. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
printf("Started service.\n");
|
||||
}
|
||||
|
||||
break;
|
||||
case 't': /*stop service*/
|
||||
if(!svc_hnd) {
|
||||
printf("Must open service first!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(stop);
|
||||
stop.in.svc_hnd = svc_hnd;
|
||||
|
||||
printf("Timeout (seconds): ");
|
||||
scanf("%d", &stop.in.timeout);
|
||||
|
||||
if(!cac_SvcStopService(hnd, mem_ctx, &stop)) {
|
||||
if(CAC_OP_FAILED(hnd->status)) {
|
||||
printf("Error occured: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
printf("Service was not stopped within %d seconds.\n", stop.in.timeout);
|
||||
print_service_status(stop.out.status);
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("Done.\n");
|
||||
print_service_status(stop.out.status);
|
||||
}
|
||||
break;
|
||||
case 'd': /*get display name*/
|
||||
if(!svc_hnd) {
|
||||
printf("Must open service first!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(gdn);
|
||||
gdn.in.svc_hnd = svc_hnd;
|
||||
|
||||
if(!cac_SvcGetDisplayName(hnd, mem_ctx, &gdn)) {
|
||||
printf("Could not get display name. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
printf("\tDisplay Name: %s\n", gdn.out.display_name);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'p': /*pause service*/
|
||||
if(!svc_hnd) {
|
||||
printf("Must open service first!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(pause);
|
||||
pause.in.svc_hnd = svc_hnd;
|
||||
|
||||
printf("Timeout (seconds): ");
|
||||
scanf("%d", &pause.in.timeout);
|
||||
|
||||
if(!cac_SvcPauseService(hnd, mem_ctx, &pause)) {
|
||||
if(CAC_OP_FAILED(hnd->status)) {
|
||||
printf("Error occured: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
printf("Service was not paused within %d seconds.\n", pause.in.timeout);
|
||||
print_service_status(pause.out.status);
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("Done.\n");
|
||||
print_service_status(pause.out.status);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'r': /*resume service*/
|
||||
if(!svc_hnd) {
|
||||
printf("Must open service first!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(res);
|
||||
res.in.svc_hnd = svc_hnd;
|
||||
|
||||
printf("Timeout (seconds): ");
|
||||
scanf("%d", &res.in.timeout);
|
||||
|
||||
if(!cac_SvcContinueService(hnd, mem_ctx, &res)) {
|
||||
if(CAC_OP_FAILED(hnd->status)) {
|
||||
printf("Error occured: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
printf("Service was not resumed within %d seconds.\n", res.in.timeout);
|
||||
print_service_status(res.out.status);
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("Done.\n");
|
||||
print_service_status(res.out.status);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'c': /*get service config*/
|
||||
if(!svc_hnd) {
|
||||
printf("Must open service first!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(sgc);
|
||||
|
||||
sgc.in.svc_hnd = svc_hnd;
|
||||
|
||||
if(!cac_SvcGetServiceConfig(hnd, mem_ctx, &sgc)) {
|
||||
printf("Could not get service config. Error: %s\n", nt_errstr(hnd->status));
|
||||
}
|
||||
else {
|
||||
print_service_config(&sgc.out.config);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'q': /*quit*/
|
||||
break;
|
||||
default:
|
||||
printf("Invalid command\n");
|
||||
}
|
||||
}
|
||||
|
||||
cac_SvcClose(hnd, mem_ctx, sos.out.scm_hnd);
|
||||
|
||||
done:
|
||||
cac_FreeHandle(hnd);
|
||||
|
||||
talloc_destroy(mem_ctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,408 +0,0 @@
|
||||
/*some utility functions for the registry tests*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
#include "test_util.h"
|
||||
|
||||
|
||||
void cactest_print_usage(char **argv) {
|
||||
printf("Usage:\n");
|
||||
printf(" %s server [-U username] [-W domain] [-P passwprd] [-N netbios_name]\n", argv[0]);
|
||||
}
|
||||
|
||||
/*allocates memory for auth info and parses domain/user/server out of command line*/
|
||||
void cac_parse_cmd_line(int argc, char **argv, CacServerHandle *hnd) {
|
||||
int i = 0;
|
||||
|
||||
ZERO_STRUCTP(hnd->username);
|
||||
ZERO_STRUCTP(hnd->domain);
|
||||
ZERO_STRUCTP(hnd->netbios_name);
|
||||
ZERO_STRUCTP(hnd->password);
|
||||
|
||||
for(i = 1; i < argc; i++) {
|
||||
if( strncmp(argv[i], "-U", sizeof(fstring)) == 0) {
|
||||
strncpy(hnd->username, argv[i+1], sizeof(fstring));
|
||||
i++;
|
||||
}
|
||||
|
||||
else if(strncmp(argv[i], "-W", sizeof(fstring)) == 0) {
|
||||
strncpy(hnd->domain, argv[i+1], sizeof(fstring));
|
||||
i++;
|
||||
|
||||
}
|
||||
|
||||
else if(strncmp(argv[i], "-P", sizeof(fstring)) == 0) {
|
||||
strncpy(hnd->password, argv[i+1], sizeof(fstring));
|
||||
i++;
|
||||
|
||||
}
|
||||
|
||||
else if(strncmp(argv[i], "-N", sizeof(fstring)) == 0) {
|
||||
strncpy(hnd->netbios_name, argv[i+1], sizeof(fstring));
|
||||
i++;
|
||||
}
|
||||
|
||||
else if(strncmp(argv[i], "-d", sizeof(fstring)) == 0) {
|
||||
sscanf(argv[i+1], "%d", &hnd->debug);
|
||||
i++;
|
||||
}
|
||||
|
||||
else { /*assume this is the server name*/
|
||||
strncpy(hnd->server, argv[i], sizeof(fstring));
|
||||
}
|
||||
}
|
||||
|
||||
if(!hnd->server) {
|
||||
cactest_print_usage(argv);
|
||||
cac_FreeHandle(hnd);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void print_value(uint32 type, REG_VALUE_DATA *data) {
|
||||
int i = 0;
|
||||
|
||||
switch(type) {
|
||||
case REG_SZ:
|
||||
printf(" Type: REG_SZ\n");
|
||||
printf(" Value: %s\n", data->reg_sz);
|
||||
break;
|
||||
case REG_EXPAND_SZ:
|
||||
printf(" Type: REG_EXPAND_SZ\n");
|
||||
printf(" Value: %s\n", data->reg_expand_sz);
|
||||
break;
|
||||
case REG_MULTI_SZ:
|
||||
printf(" Type: REG_MULTI_SZ\n");
|
||||
printf(" Values: ");
|
||||
|
||||
for(i = 0; i < data->reg_multi_sz.num_strings; i++) {
|
||||
printf(" %d: %s\n", i, data->reg_multi_sz.strings[i]);
|
||||
}
|
||||
break;
|
||||
case REG_DWORD:
|
||||
printf(" Type: REG_DWORD\n");
|
||||
printf(" Value: %d\n", data->reg_dword);
|
||||
break;
|
||||
case REG_DWORD_BE:
|
||||
printf(" Type: REG_DWORD_BE\n");
|
||||
printf(" Value: 0x%x\n", data->reg_dword_be);
|
||||
break;
|
||||
case REG_BINARY:
|
||||
printf(" Type: REG_BINARY\n");
|
||||
break;
|
||||
default:
|
||||
printf(" Invalid type: %d\n", type);
|
||||
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
}
|
||||
|
||||
void cactest_readline(FILE *in, fstring line) {
|
||||
|
||||
int c;
|
||||
|
||||
c = fgetc(in);
|
||||
if(c != '\n')
|
||||
ungetc(c, in);
|
||||
|
||||
fgets(line, sizeof(fstring), in);
|
||||
|
||||
if(line[strlen(line) - 1] == '\n')
|
||||
line[strlen(line) - 1] = '\0';
|
||||
|
||||
}
|
||||
|
||||
void cactest_GetAuthDataFn(const char * pServer,
|
||||
const char * pShare,
|
||||
char * pWorkgroup,
|
||||
int maxLenWorkgroup,
|
||||
char * pUsername,
|
||||
int maxLenUsername,
|
||||
char * pPassword,
|
||||
int maxLenPassword)
|
||||
|
||||
{
|
||||
char temp[sizeof(fstring)];
|
||||
|
||||
static char authUsername[sizeof(fstring)];
|
||||
static char authWorkgroup[sizeof(fstring)];
|
||||
static char authPassword[sizeof(fstring)];
|
||||
static char authSet = 0;
|
||||
|
||||
char *pass = NULL;
|
||||
|
||||
if (authSet)
|
||||
{
|
||||
strncpy(pWorkgroup, authWorkgroup, maxLenWorkgroup - 1);
|
||||
strncpy(pUsername, authUsername, maxLenUsername - 1);
|
||||
strncpy(pPassword, authPassword, maxLenPassword - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(pWorkgroup[0] != '\0') {
|
||||
strncpy(authWorkgroup, pWorkgroup, maxLenWorkgroup - 1);
|
||||
}
|
||||
else {
|
||||
d_printf("Domain: [%s] ", pWorkgroup);
|
||||
fscanf(stdin, "%s", temp);
|
||||
|
||||
if (temp[0] != '\0')
|
||||
{
|
||||
strncpy(pWorkgroup, temp, maxLenWorkgroup - 1);
|
||||
strncpy(authWorkgroup, temp, maxLenWorkgroup - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(pUsername[0] != '\0') {
|
||||
strncpy(authUsername, pUsername, maxLenUsername - 1);
|
||||
}
|
||||
else {
|
||||
d_printf("Username: [%s] ", pUsername);
|
||||
fscanf(stdin, "%s", temp);
|
||||
|
||||
if (temp[strlen(temp) - 1] == '\n') /* A new line? */
|
||||
{
|
||||
temp[strlen(temp) - 1] = '\0';
|
||||
}
|
||||
|
||||
if (temp[0] != '\0')
|
||||
{
|
||||
strncpy(pUsername, temp, maxLenUsername - 1);
|
||||
strncpy(authUsername, pUsername, maxLenUsername - 1);
|
||||
}
|
||||
}
|
||||
if(pPassword[0] != '\0') {
|
||||
strncpy(authPassword, pPassword, maxLenPassword - 1);
|
||||
}
|
||||
else {
|
||||
pass = getpass("Password: ");
|
||||
if (pass)
|
||||
fstrcpy(temp, pass);
|
||||
if (temp[strlen(temp) - 1] == '\n') /* A new line? */
|
||||
{
|
||||
temp[strlen(temp) - 1] = '\0';
|
||||
}
|
||||
if (temp[0] != '\0')
|
||||
{
|
||||
strncpy(pPassword, temp, maxLenPassword - 1);
|
||||
strncpy(authPassword, pPassword, maxLenPassword - 1);
|
||||
}
|
||||
}
|
||||
authSet = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void cactest_reg_input_val(TALLOC_CTX *mem_ctx, int *type, char **name, REG_VALUE_DATA *data) {
|
||||
fstring tmp;
|
||||
int i;
|
||||
|
||||
printf("Enter value name: \n");
|
||||
cactest_readline(stdin, tmp);
|
||||
*name = talloc_strdup(mem_ctx, tmp);
|
||||
|
||||
do {
|
||||
printf("Enter type. %d = REG_SZ, %d = REG_DWORD, %d = REG_MULTI_SZ: ", REG_SZ, REG_DWORD, REG_MULTI_SZ);
|
||||
scanf("%d", type);
|
||||
} while(*type != REG_SZ && *type != REG_DWORD && *type != REG_MULTI_SZ);
|
||||
|
||||
switch(*type) {
|
||||
case REG_SZ:
|
||||
printf("Enter string:\n");
|
||||
cactest_readline(stdin, tmp);
|
||||
|
||||
data->reg_sz = talloc_strdup(mem_ctx, tmp);
|
||||
break;
|
||||
|
||||
case REG_DWORD:
|
||||
printf("Enter dword: ");
|
||||
scanf("%d", &data->reg_dword);
|
||||
break;
|
||||
|
||||
case REG_MULTI_SZ:
|
||||
printf("Enter number of strings: ");
|
||||
scanf("%d", &data->reg_multi_sz.num_strings);
|
||||
|
||||
data->reg_multi_sz.strings = talloc_array(mem_ctx, char *, data->reg_multi_sz.num_strings);
|
||||
|
||||
for(i = 0; i < data->reg_multi_sz.num_strings; i++) {
|
||||
printf("String %d: ", i+1);
|
||||
cactest_readline(stdin, tmp);
|
||||
|
||||
data->reg_multi_sz.strings[i] = talloc_strdup(mem_ctx, tmp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void print_cac_user_info(CacUserInfo *info) {
|
||||
printf(" User Name : %s\n", info->username);
|
||||
printf(" Full Name : %s\n", info->full_name);
|
||||
printf(" Home Dir : %s\n", info->home_dir);
|
||||
printf(" Home Drive : %s\n", info->home_drive);
|
||||
printf(" Profile Path : %s\n", info->profile_path);
|
||||
printf(" Logon Script : %s\n", info->logon_script);
|
||||
printf(" Description : %s\n", info->description);
|
||||
printf(" Workstations : %s\n", info->workstations);
|
||||
printf(" Remote Dial : %s\n", info->dial);
|
||||
|
||||
printf(" Logon Time : %s\n", http_timestring(info->logon_time));
|
||||
printf(" Logoff Time : %s\n", http_timestring(info->logoff_time));
|
||||
printf(" Kickoff Time : %s\n", http_timestring(info->kickoff_time));
|
||||
printf(" Pass last set: %s\n", http_timestring(info->pass_last_set_time));
|
||||
printf(" Pass can set : %s\n", http_timestring(info->pass_can_change_time));
|
||||
printf(" Pass must set: %s\n", http_timestring(info->pass_must_change_time));
|
||||
|
||||
printf(" User RID : 0x%x\n", info->rid);
|
||||
printf(" Group RID : 0x%x\n", info->group_rid);
|
||||
printf(" ACB Mask : 0x%x\n", info->acb_mask);
|
||||
|
||||
printf(" Bad pwd count: %d\n", info->bad_passwd_count);
|
||||
printf(" Logon Cuont : %d\n", info->logon_count);
|
||||
|
||||
printf(" NT Password : %s\n", info->nt_password);
|
||||
printf(" LM Password : %s\n", info->lm_password);
|
||||
|
||||
}
|
||||
|
||||
void edit_readline(fstring line) {
|
||||
fgets(line, sizeof(fstring), stdin);
|
||||
|
||||
if(line[strlen(line)-1] == '\n')
|
||||
line[strlen(line)-1] = '\0';
|
||||
}
|
||||
void edit_cac_user_info(TALLOC_CTX *mem_ctx, CacUserInfo *info) {
|
||||
fstring tmp;
|
||||
|
||||
printf(" User Name [%s]: ", info->username);
|
||||
edit_readline(tmp);
|
||||
|
||||
if(tmp[0] != '\0')
|
||||
info->username = talloc_strdup(mem_ctx, tmp);
|
||||
|
||||
printf(" Full Name [%s]: ", info->full_name);
|
||||
|
||||
edit_readline(tmp);
|
||||
if(tmp[0] != '\0')
|
||||
info->full_name = talloc_strdup(mem_ctx, tmp);
|
||||
|
||||
printf(" Description [%s]: ", info->description);
|
||||
edit_readline(tmp);
|
||||
if(tmp[0] != '\0')
|
||||
info->description = talloc_strdup(mem_ctx, tmp);
|
||||
|
||||
printf(" Remote Dial [%s]: ", info->dial);
|
||||
edit_readline(tmp);
|
||||
if(tmp[0] != '\0')
|
||||
info->dial = talloc_strdup(mem_ctx, tmp);
|
||||
|
||||
printf(" ACB Mask [0x%x]: ", info->acb_mask);
|
||||
edit_readline(tmp);
|
||||
if(tmp[0] != '\0')
|
||||
sscanf(tmp, "%x", &info->acb_mask);
|
||||
|
||||
printf(" Must change pass at next logon? [y/N]: ");
|
||||
edit_readline(tmp);
|
||||
|
||||
if(tmp[0] == 'y' || tmp[0] == 'Y')
|
||||
info->pass_must_change= True;
|
||||
|
||||
}
|
||||
|
||||
void print_cac_group_info(CacGroupInfo *info) {
|
||||
printf(" Group Name : %s\n", info->name);
|
||||
printf(" Description : %s\n", info->description);
|
||||
printf(" Num Members : %d\n", info->num_members);
|
||||
}
|
||||
|
||||
void edit_cac_group_info(TALLOC_CTX *mem_ctx, CacGroupInfo *info) {
|
||||
fstring tmp;
|
||||
|
||||
printf("Group Name [%s]: ", info->name);
|
||||
edit_readline(tmp);
|
||||
if(tmp[0] != '\0')
|
||||
info->name = talloc_strdup(mem_ctx, tmp);
|
||||
|
||||
printf("Description [%s]: ", info->description);
|
||||
edit_readline(tmp);
|
||||
if(tmp[0] != '\0')
|
||||
info->description = talloc_strdup(mem_ctx, tmp);
|
||||
}
|
||||
|
||||
char *srv_role_str(uint32 role) {
|
||||
switch(role) {
|
||||
case ROLE_STANDALONE:
|
||||
return "STANDALONE";
|
||||
break;
|
||||
case ROLE_DOMAIN_MEMBER:
|
||||
return "DOMAIN_MEMBER";
|
||||
break;
|
||||
case ROLE_DOMAIN_BDC:
|
||||
return "DOMAIN_BDC";
|
||||
break;
|
||||
case ROLE_DOMAIN_PDC:
|
||||
return "DOMAIN_PDC";
|
||||
break;
|
||||
}
|
||||
|
||||
return "Invalid role!\n";
|
||||
}
|
||||
|
||||
char *cactime_str(CacTime ctime, fstring tmp) {
|
||||
|
||||
snprintf(tmp, sizeof(fstring), "%u Days, %u Hours, %u Minutes, %u Seconds", ctime.days, ctime.hours, ctime.minutes, ctime.seconds);
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
void print_cac_domain_info(CacDomainInfo *info) {
|
||||
fstring tmp;
|
||||
|
||||
printf(" Server Role : %s\n", srv_role_str(info->server_role));
|
||||
printf(" Num Users : %d\n", info->num_users);
|
||||
printf(" Num Domain Groups: %d\n", info->num_domain_groups);
|
||||
printf(" Num Local Groups : %d\n", info->num_local_groups);
|
||||
printf(" Comment : %s\n", info->comment);
|
||||
printf(" Domain Name : %s\n", info->domain_name);
|
||||
printf(" Server Name : %s\n", info->server_name);
|
||||
printf(" Min. Pass. Length: %d\n", info->min_pass_length);
|
||||
printf(" Password History : %d\n", info->pass_history);
|
||||
printf("\n");
|
||||
printf(" Passwords Expire In : %s\n", cactime_str(info->expire, tmp));
|
||||
printf(" Passwords Can Change in: %s\n", cactime_str(info->min_pass_age, tmp));
|
||||
printf(" Lockouts last : %s\n", cactime_str(info->lockout_duration, tmp));
|
||||
printf(" Allowed Bad Attempts : %d\n", info->num_bad_attempts);
|
||||
}
|
||||
|
||||
void print_cac_service(CacService svc) {
|
||||
printf("\tService Name: %s\n", svc.service_name);
|
||||
printf("\tDisplay Name: %s\n", svc.display_name);
|
||||
print_service_status(svc.status);
|
||||
}
|
||||
|
||||
void print_service_status(SERVICE_STATUS status) {
|
||||
printf("\tStatus:\n");
|
||||
printf("\t Type: 0x%x\n", status.type);
|
||||
printf("\t State: 0x%x\n", status.state);
|
||||
printf("\t Controls: 0x%x\n", status.controls_accepted);
|
||||
printf("\t W32 Exit Code: 0x%x\n", status.win32_exit_code);
|
||||
printf("\t SVC Exit Code: 0x%x\n", status.service_exit_code);
|
||||
printf("\t Checkpoint: 0x%x\n", status.check_point);
|
||||
printf("\t Wait Hint: 0x%x\n", status.wait_hint);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void print_service_config(CacServiceConfig *config) {
|
||||
printf("\tConfig:\n");
|
||||
printf("\tType: 0x%x\n", config->type);
|
||||
printf("\tStart Type: 0x%x\n", config->start_type);
|
||||
printf("\tError config: 0x%x\n", config->error_control);
|
||||
printf("\tExecutable Path: %s\n", config->exe_path);
|
||||
printf("\tLoad Order Group: %s\n", config->load_order_group);
|
||||
printf("\tTag ID: 0x%x\n", config->tag_id);
|
||||
printf("\tDependencies: %s\n", config->dependencies);
|
||||
printf("\tStart Name: %s\n", config->start_name);
|
||||
printf("\tDisplay Name: %s\n", config->display_name);
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
#ifndef TEST_UTIL_H
|
||||
#define TEST_UTIL_H
|
||||
|
||||
#include "libmsrpc.h"
|
||||
|
||||
/*prototypes*/
|
||||
void cactest_GetAuthDataFn(const char * pServer,
|
||||
const char * pShare,
|
||||
char * pWorkgroup,
|
||||
int maxLenWorkgroup,
|
||||
char * pUsername,
|
||||
int maxLenUsername,
|
||||
char * pPassword,
|
||||
int maxLenPassword);
|
||||
|
||||
|
||||
void cactest_print_usage(char **argv);
|
||||
void cac_parse_cmd_line(int argc, char **argv, CacServerHandle *hnd);
|
||||
void print_value(uint32 type, REG_VALUE_DATA *data);
|
||||
void cactest_readline(FILE *in, fstring line);
|
||||
void cactest_reg_input_val(TALLOC_CTX *mem_ctx, int *type, char **name, REG_VALUE_DATA *data);
|
||||
void print_cac_user_info(CacUserInfo *info);
|
||||
void edit_cac_user_info(TALLOC_CTX *mem_ctx, CacUserInfo *info);
|
||||
void print_cac_group_info(CacGroupInfo *info);
|
||||
void edit_cac_group_info(TALLOC_CTX *mem_ctx, CacGroupInfo *info);
|
||||
void print_cac_domain_info(CacDomainInfo *info);
|
||||
void print_cac_service(CacService svc);
|
||||
void print_service_status(SERVICE_STATUS status);
|
||||
void print_service_config(CacServiceConfig *config);
|
||||
|
||||
#endif /*TEST_UTIL_H*/
|
@ -1,166 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
#
|
||||
# adduserstogroups.pl
|
||||
#
|
||||
# add single or continuously numbered domain users
|
||||
# to a given single group or list of groups
|
||||
#
|
||||
# Copyright (C) Michael Adam <obnox@samba.org> 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
#
|
||||
# WARNING: This script is still rather crude.
|
||||
#
|
||||
|
||||
use strict;
|
||||
use Getopt::Std;
|
||||
|
||||
my $net_cmd = "net";
|
||||
|
||||
# defaults:
|
||||
|
||||
my $server;
|
||||
my $num_members = 1;
|
||||
my $startmem; # if empty, don't add numbers to member prefix
|
||||
my $member_prefix; # name prefix for member
|
||||
my $num_groups = 1;
|
||||
my $startgroup; # if empty, don't add numbers to group prefix
|
||||
my $group_prefix; # name prefix for group
|
||||
my $path; # path to rpcclient command
|
||||
my $net_path = $net_cmd;
|
||||
my $creds;
|
||||
|
||||
sub usage {
|
||||
print "USAGE: $0 [-h] -S server -U user\%pass \\\n"
|
||||
. "\t-m member [-s startmem] [-n nummem] \\\n"
|
||||
. "\t-g group [-G stargroup] [-N numgroups] \\\n"
|
||||
. "\t[-P path]\n";
|
||||
}
|
||||
|
||||
# parse commandline:
|
||||
|
||||
my %options = ();
|
||||
getopts("U:S:m:s:n:g:G:N:P:h", \%options);
|
||||
|
||||
if (exists($options{h})) {
|
||||
usage();
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if (exists($options{g})) {
|
||||
$group_prefix = $options{g};
|
||||
}
|
||||
else {
|
||||
print "ERROR: mandatory argument '-g' missing\n";
|
||||
usage();
|
||||
exit 1;
|
||||
}
|
||||
|
||||
if (exists($options{U})) {
|
||||
$creds = "-U $options{U}";
|
||||
if ($creds !~ '%') {
|
||||
print "ERROR: you need to specify credentials in the form -U user\%pass\n";
|
||||
usage();
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
print "ERROR: mandatory argument '-U' missing\n";
|
||||
usage();
|
||||
exit 1;
|
||||
}
|
||||
|
||||
if (exists($options{S})) {
|
||||
$server = $options{S};
|
||||
}
|
||||
else {
|
||||
print "ERROR: madatory argument '-S' missing\n";
|
||||
usage();
|
||||
exit 1;
|
||||
}
|
||||
|
||||
if (exists($options{s})) {
|
||||
$startmem = $options{s};
|
||||
}
|
||||
|
||||
if (exists($options{n})) {
|
||||
$num_members = $options{n};
|
||||
}
|
||||
|
||||
if (exists($options{m})) {
|
||||
$member_prefix = $options{m};
|
||||
}
|
||||
else {
|
||||
print "ERROR: mandatory argument '-m' missing\n";
|
||||
usage();
|
||||
exit 1;
|
||||
}
|
||||
|
||||
if (exists($options{G})) {
|
||||
$startgroup = $options{G};
|
||||
}
|
||||
|
||||
if (exists($options{N})) {
|
||||
$num_groups = $options{N};
|
||||
}
|
||||
|
||||
if (exists($options{P})) {
|
||||
$path = $options{p};
|
||||
$net_path = "$path/$net_cmd";
|
||||
}
|
||||
|
||||
if (@ARGV) {
|
||||
print "ERROR: junk on the command line ('" . join(" ", @ARGV) . "')...\n";
|
||||
usage();
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# utility functions:
|
||||
|
||||
sub do_add {
|
||||
my $member_name = shift;
|
||||
my $group_name = shift;
|
||||
print "adding member $member_name to group $group_name\n";
|
||||
system("$net_path rpc -I $server ".$creds." group addmem $group_name $member_name");
|
||||
}
|
||||
|
||||
sub add_group_loop {
|
||||
my $member_name = shift;
|
||||
|
||||
if ("x$startgroup" eq "x") {
|
||||
do_add($member_name, $group_prefix);
|
||||
}
|
||||
else {
|
||||
for (my $groupnum = 1; $groupnum <= $num_groups; ++$groupnum) {
|
||||
do_add($member_name,
|
||||
sprintf("%s%.05d", $group_prefix, $startgroup + $groupnum - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# main:
|
||||
|
||||
if ("x$startmem" eq "x") {
|
||||
add_group_loop($member_prefix);
|
||||
}
|
||||
else {
|
||||
for (my $memnum = 1; $memnum <= $num_members; ++$memnum) {
|
||||
add_group_loop(sprintf("%s%.05d", $member_prefix, $startmem + $memnum - 1));
|
||||
}
|
||||
}
|
||||
|
@ -1,157 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
#
|
||||
# createdomobj.pl
|
||||
#
|
||||
# create single or continuously numbered domain
|
||||
# users/groups/aliases via rpc
|
||||
#
|
||||
# Copyright (C) Michael Adam <obnox@samba.org> 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
#
|
||||
# WARNING: This script is still rather crude.
|
||||
#
|
||||
|
||||
use strict;
|
||||
use Getopt::Std;
|
||||
|
||||
|
||||
my $target_type = "group"; # what type of object to create
|
||||
my $rpc_cmd = "createdom".$target_type;
|
||||
my $rpccli_cmd = "rpcclient";
|
||||
|
||||
# defaults:
|
||||
|
||||
my $server;
|
||||
my $num_targets = 1;
|
||||
my $startnum; # if empty, don't add numbers to prefix
|
||||
my $prefix = $target_type; # name-prefix
|
||||
my $path; # path to rpcclient command
|
||||
my $rpccli_path = $rpccli_cmd;
|
||||
my $creds;
|
||||
|
||||
sub usage {
|
||||
print "USAGE: $0 [-h] -S server -U user\%pass [-p prefix] \\\n"
|
||||
. "\t[-t {alias|group|user}] [-s startnum] [-n numobjs] [-P path] \n";
|
||||
}
|
||||
|
||||
# parse commandline:
|
||||
|
||||
my %options = ();
|
||||
getopts("U:t:S:s:n:p:P:h", \%options);
|
||||
|
||||
if (exists($options{h})) {
|
||||
usage();
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if (exists($options{t})) {
|
||||
$target_type = $options{t};
|
||||
if ($target_type !~ /^(alias|user|group)$/) {
|
||||
print "ERROR: invalid target type given\n";
|
||||
usage();
|
||||
exit 1;
|
||||
}
|
||||
$rpc_cmd = "createdom".$target_type;
|
||||
}
|
||||
|
||||
if (exists($options{U})) {
|
||||
$creds = "-U $options{U}";
|
||||
if ($creds !~ '%') {
|
||||
print "ERROR: you need to specify credentials in the form -U user\%pass\n";
|
||||
usage();
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
print "ERROR: mandatory argument '-U' missing\n";
|
||||
usage();
|
||||
exit 1;
|
||||
}
|
||||
|
||||
if (exists($options{S})) {
|
||||
$server = $options{S};
|
||||
}
|
||||
else {
|
||||
print "ERROR: madatory argument '-S' missing\n";
|
||||
usage();
|
||||
exit 1;
|
||||
}
|
||||
|
||||
if (exists($options{s})) {
|
||||
$startnum = $options{s};
|
||||
}
|
||||
|
||||
if (exists($options{n})) {
|
||||
$num_targets = $options{n};
|
||||
}
|
||||
|
||||
if (exists($options{p})) {
|
||||
$prefix = $options{p};
|
||||
}
|
||||
|
||||
if (exists($options{P})) {
|
||||
$path = $options{p};
|
||||
$rpccli_path = "$path/$rpccli_cmd";
|
||||
}
|
||||
|
||||
if (@ARGV) {
|
||||
print "ERROR: junk on the command line ('" . join(" ", @ARGV) . "')...\n";
|
||||
usage();
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# utility functions:
|
||||
|
||||
sub open_rpc_pipe {
|
||||
print "opening rpc pipe\n";
|
||||
open(IPC, "| $rpccli_cmd $server $creds -d0") or
|
||||
die "error opening rpc pipe.";
|
||||
}
|
||||
|
||||
sub close_rpc_pipe {
|
||||
print "closing rpc pipe\n";
|
||||
close(IPC);
|
||||
}
|
||||
|
||||
sub do_create {
|
||||
my $target_name = shift;
|
||||
print "creating $target_type $target_name\n";
|
||||
print IPC "$rpc_cmd $target_name\n";
|
||||
}
|
||||
|
||||
# main:
|
||||
|
||||
open_rpc_pipe();
|
||||
|
||||
if ("x$startnum" eq "x") {
|
||||
do_create($prefix);
|
||||
}
|
||||
else {
|
||||
for (my $num = 1; $num <= $num_targets; ++$num) {
|
||||
do_create(sprintf "%s%.05d", $prefix, $startnum + $num - 1);
|
||||
if (($num) % 500 == 0) {
|
||||
printf("500 ".$target_type."s created\n");
|
||||
close_rpc_pipe();
|
||||
sleep 2;
|
||||
open_rpc_pipe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close_rpc_pipe();
|
||||
|
@ -1,67 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
## A simple script to build a tarball of the current CVS tree.
|
||||
## You either need to include the using_samba cvs module in the
|
||||
## parent directory or tell the script where to find it
|
||||
##
|
||||
## Usgae: ./make-tarball.sh [nodocs]
|
||||
|
||||
NODOCS=0
|
||||
if [ x"$1" = x"nodocs" ] ; then
|
||||
NODOCS=1
|
||||
echo Not including docs.
|
||||
fi
|
||||
|
||||
DOCSDIR=../samba-docs/
|
||||
USING_SAMBA=../using_samba/
|
||||
SRCDIR=`pwd`
|
||||
|
||||
if [ $NODOCS -eq 0 ]; then
|
||||
if [ ! -d $USING_SAMBA ]; then
|
||||
|
||||
echo Cannot find "Using Samba" directory \(assuming $USING_SAMBA\).
|
||||
echo Please set the USING_SAMBA variable in this script to the correct
|
||||
echo location. The html files are available in the using_samba CVS
|
||||
echo module on cvs.samba.org. See http://cvs.samba.org/ for details
|
||||
echo about anonymous CVS access. Exiting now....
|
||||
|
||||
exit 1
|
||||
|
||||
fi
|
||||
|
||||
if [ ! -d $DOCSDIR ]; then
|
||||
|
||||
echo Cannot find samba-docs \(assuming $DOCSDIR\).
|
||||
echo Please set the DOCSDIR variable in this script
|
||||
echo to the correct path.
|
||||
|
||||
exit 1
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
( cd source ; sh script/mkversion.sh )
|
||||
VERSION=`grep SAMBA_VERSION_OFFICIAL_STRING source/include/version.h | cut -d\" -f2 | sed 's/ /_/g'`
|
||||
TARBALLDIR=/tmp/samba-$VERSION
|
||||
|
||||
echo Creating the tarball source directory in $TARBALLDIR
|
||||
|
||||
/bin/rm -rf $TARBALLDIR
|
||||
/bin/rm -f samba-$VERSION.tar
|
||||
|
||||
mkdir $TARBALLDIR
|
||||
rsync -aC ./ $TARBALLDIR
|
||||
/bin/rm -rf $TARBALLDIR/docs/*
|
||||
if [ $NODOCS -eq 0 ]; then
|
||||
rsync -aC $DOCSDIR/ $TARBALLDIR/docs/
|
||||
rsync -aC $USING_SAMBA $TARBALLDIR/docs/htmldocs/
|
||||
fi
|
||||
|
||||
echo Creating packaging scripts...
|
||||
( cd $TARBALLDIR/packaging; sh bin/update-pkginfo $VERSION 1 )
|
||||
|
||||
echo Creating source/configure...
|
||||
( cd $TARBALLDIR/source; ./autogen.sh )
|
||||
|
||||
echo Making tarball samba-$VERSION.tar in current directory...
|
||||
( cd `dirname $TARBALLDIR`; tar cf $SRCDIR/samba-$VERSION.tar samba-$VERSION )
|
30
source3/.indent.pro
vendored
Normal file
30
source3/.indent.pro
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
-bad
|
||||
-bap
|
||||
-bbb
|
||||
-br
|
||||
-ce
|
||||
-ut
|
||||
-ts8
|
||||
-i8
|
||||
-di1
|
||||
-brs
|
||||
-npsl
|
||||
-npcs
|
||||
-prs
|
||||
-bbo
|
||||
-hnl
|
||||
-bad
|
||||
-bap
|
||||
-bbb
|
||||
-br
|
||||
-ce
|
||||
-ut
|
||||
-ts8
|
||||
-i8
|
||||
-di1
|
||||
-brs
|
||||
-npsl
|
||||
-npcs
|
||||
-prs
|
||||
-bbo
|
||||
-hnl
|
@ -1,85 +0,0 @@
|
||||
# add valgrind suppressions for the build farm here. Get the format
|
||||
# from the build farm log
|
||||
|
||||
{
|
||||
samba_dlopen1
|
||||
Memcheck:Cond
|
||||
obj:/lib/ld-2.3.6.so
|
||||
obj:/lib/ld-2.3.6.so
|
||||
obj:/lib/tls/libc-2.3.6.so
|
||||
obj:/lib/ld-2.3.6.so
|
||||
fun:_dl_open
|
||||
}
|
||||
|
||||
{
|
||||
samba_dlopen2
|
||||
Memcheck:Cond
|
||||
obj:/lib/ld-2.3.6.so
|
||||
fun:_dl_open
|
||||
}
|
||||
|
||||
{
|
||||
samba_dlopen3
|
||||
Memcheck:Addr4
|
||||
obj:/lib/ld-2.3.6.so
|
||||
obj:/lib/ld-2.3.6.so
|
||||
obj:/lib/ld-2.3.6.so
|
||||
obj:/lib/ld-2.3.6.so
|
||||
obj:/lib/ld-2.3.6.so
|
||||
obj:/lib/ld-2.3.6.so
|
||||
obj:/lib/tls/libc-2.3.6.so
|
||||
obj:/lib/ld-2.3.6.so
|
||||
fun:_dl_open
|
||||
}
|
||||
|
||||
{
|
||||
samba_dlopen4
|
||||
Memcheck:Cond
|
||||
obj:/lib/ld-2.3.6.so
|
||||
obj:/lib/tls/libc-2.3.6.so
|
||||
obj:/lib/ld-2.3.6.so
|
||||
fun:_dl_open
|
||||
}
|
||||
|
||||
{
|
||||
samba_dlopen5
|
||||
Memcheck:Addr4
|
||||
obj:/lib/ld-2.3.6.so
|
||||
obj:/lib/ld-2.3.6.so
|
||||
obj:/lib/ld-2.3.6.so
|
||||
obj:/lib/tls/libc-2.3.6.so
|
||||
obj:/lib/ld-2.3.6.so
|
||||
fun:_dl_open
|
||||
}
|
||||
|
||||
{
|
||||
samba_dlopen6
|
||||
Memcheck:Cond
|
||||
obj:/lib/ld-2.3.6.so
|
||||
obj:/lib/ld-2.3.6.so
|
||||
obj:/lib/ld-2.3.6.so
|
||||
obj:/lib/tls/libc-2.3.6.so
|
||||
obj:/lib/ld-2.3.6.so
|
||||
fun:_dl_open
|
||||
}
|
||||
|
||||
{
|
||||
samba_dlopen7
|
||||
Memcheck:Addr4
|
||||
obj:/lib/ld-2.3.6.so
|
||||
obj:/lib/ld-2.3.6.so
|
||||
obj:/lib/tls/libc-2.3.6.so
|
||||
obj:/lib/ld-2.3.6.so
|
||||
fun:_dl_open
|
||||
}
|
||||
|
||||
{
|
||||
samba_libc_dlsym1
|
||||
Memcheck:Addr4
|
||||
obj:/lib/ld-2.3.6.so
|
||||
obj:/lib/ld-2.3.6.so
|
||||
obj:/lib/ld-2.3.6.so
|
||||
obj:/lib/tls/libc-2.3.6.so
|
||||
obj:/lib/ld-2.3.6.so
|
||||
fun:__libc_dlsym
|
||||
}
|
@ -168,3 +168,9 @@ DOT_CLEANUP = YES
|
||||
# configuration::additions related to the search engine
|
||||
#---------------------------------------------------------------------------
|
||||
SEARCHENGINE = NO
|
||||
CGI_NAME = search.cgi
|
||||
CGI_URL =
|
||||
DOC_URL =
|
||||
DOC_ABSPATH =
|
||||
BIN_ABSPATH = /usr/local/bin/
|
||||
EXT_DOC_PATHS =
|
||||
|
@ -16,7 +16,7 @@ localstatedir=@localstatedir@
|
||||
datarootdir=@datarootdir@
|
||||
|
||||
selftest_prefix=@selftest_prefix@
|
||||
samba4srcdir=@samba4srcdir@
|
||||
smbtorture4_path=@smbtorture4_path@
|
||||
|
||||
LIBS=@LIBS@
|
||||
CC=@CC@
|
||||
@ -48,13 +48,10 @@ WINBIND_NSS_LDSHFLAGS=@WINBIND_NSS_LDSHFLAGS@ @LDFLAGS@
|
||||
AWK=@AWK@
|
||||
PICFLAG=@PICFLAG@
|
||||
DYNEXP=@DYNEXP@
|
||||
PYTHON=@PYTHON@
|
||||
PERL=@PERL@
|
||||
|
||||
PIDL_ARGS=@PIDL_ARGS@
|
||||
|
||||
SELFTEST_ARGS = @SELFTEST_ARGS@
|
||||
|
||||
TERMLDFLAGS=@TERMLDFLAGS@
|
||||
TERMLIBS=@TERMLIBS@
|
||||
PRINT_LIBS=@PRINT_LIBS@
|
||||
@ -134,7 +131,6 @@ LOCKDIR = @lockdir@
|
||||
PIDDIR = @piddir@
|
||||
|
||||
LIBSMBCLIENT=bin/libsmbclient.a @LIBSMBCLIENT_SHARED@
|
||||
LIBMSRPC=bin/libmsrpc.a @LIBMSRPC_SHARED@
|
||||
LIBSMBSHAREMODES=bin/libsmbsharemodes.a @LIBSMBSHAREMODES_SHARED@
|
||||
LIBADDNS=bin/libaddns.a @LIBADDNS_SHARED@
|
||||
|
||||
@ -254,9 +250,7 @@ LIBNDR_GEN_OBJ = librpc/gen_ndr/ndr_wkssvc.o \
|
||||
librpc/gen_ndr/ndr_srvsvc.o \
|
||||
librpc/gen_ndr/ndr_svcctl.o \
|
||||
librpc/gen_ndr/ndr_eventlog.o \
|
||||
librpc/gen_ndr/ndr_unixinfo.o \
|
||||
librpc/gen_ndr/ndr_notify.o \
|
||||
librpc/gen_ndr/ndr_epmapper.o
|
||||
librpc/gen_ndr/ndr_notify.o
|
||||
|
||||
RPC_PARSE_OBJ0 = rpc_parse/parse_prs.o rpc_parse/parse_misc.o
|
||||
|
||||
@ -264,7 +258,7 @@ RPC_PARSE_OBJ0 = rpc_parse/parse_prs.o rpc_parse/parse_misc.o
|
||||
# that requires knowledge of security contexts
|
||||
RPC_PARSE_OBJ1 = $(RPC_PARSE_OBJ0) rpc_parse/parse_sec.o
|
||||
|
||||
RPC_PARSE_OBJ2 = rpc_parse/parse_rpc.o rpc_parse/parse_net.o
|
||||
RPC_PARSE_OBJ2 = rpc_parse/parse_rpc.o rpc_parse/parse_net.o rpc_parse/parse_srv.o
|
||||
|
||||
LIBREPLACE_OBJ = @LIBREPLACE_OBJS@
|
||||
|
||||
@ -351,10 +345,10 @@ LIBSMB_OBJ = libsmb/clientgen.o libsmb/cliconnect.o libsmb/clifile.o \
|
||||
libsmb/clistr.o libsmb/cliquota.o libsmb/clifsinfo.o libsmb/clidfs.o \
|
||||
libsmb/smberr.o libsmb/credentials.o libsmb/pwd_cache.o \
|
||||
libsmb/clioplock.o $(ERRORMAP_OBJ) libsmb/clirap2.o \
|
||||
libsmb/smb_seal.o $(DOSERR_OBJ) \
|
||||
$(DOSERR_OBJ) \
|
||||
$(RPC_PARSE_OBJ1) $(LIBSAMBA_OBJ) $(LIBNMB_OBJ)
|
||||
|
||||
RPC_CLIENT_OBJ1 = rpc_client/cli_netlogon.o
|
||||
RPC_CLIENT_OBJ1 = rpc_client/cli_netlogon.o rpc_client/cli_srvsvc.o
|
||||
|
||||
LIBMSRPC_OBJ = rpc_client/cli_lsarpc.o rpc_client/cli_samr.o \
|
||||
$(RPC_CLIENT_OBJ1) rpc_client/cli_reg.o $(RPC_CLIENT_OBJ) \
|
||||
@ -369,8 +363,7 @@ LIBMSRPC_GEN_OBJ = librpc/gen_ndr/cli_lsa.o \
|
||||
librpc/gen_ndr/cli_winreg.o \
|
||||
librpc/gen_ndr/cli_initshutdown.o \
|
||||
librpc/gen_ndr/cli_eventlog.o \
|
||||
librpc/gen_ndr/cli_unixinfo.o \
|
||||
librpc/gen_ndr/cli_epmapper.o \
|
||||
librpc/gen_ndr/cli_wkssvc.o \
|
||||
$(LIBNDR_GEN_OBJ) \
|
||||
$(RPCCLIENT_NDR_OBJ)
|
||||
|
||||
@ -390,19 +383,18 @@ RPC_NETLOG_OBJ = rpc_server/srv_netlog.o rpc_server/srv_netlog_nt.o
|
||||
RPC_SAMR_OBJ = rpc_server/srv_samr.o rpc_server/srv_samr_nt.o \
|
||||
rpc_server/srv_samr_util.o
|
||||
|
||||
RPC_UNIXINFO_OBJ = librpc/gen_ndr/srv_unixinfo.o rpc_server/srv_unixinfo_nt.o
|
||||
REGFIO_OBJ = registry/regfio.o
|
||||
|
||||
RPC_EPMAPPER_OBJ = librpc/gen_ndr/srv_epmapper.o rpc_server/srv_epmapper_nt.o
|
||||
|
||||
RPC_INITSHUTDOWN_OBJ = librpc/gen_ndr/srv_initshutdown.o rpc_server/srv_initshutdown_nt.o
|
||||
|
||||
RPC_REG_OBJ = rpc_server/srv_winreg_nt.o \
|
||||
librpc/gen_ndr/srv_winreg.o \
|
||||
$(REGFIO_OBJ)
|
||||
|
||||
RPC_LSA_DS_OBJ = rpc_server/srv_lsa_ds.o rpc_server/srv_lsa_ds_nt.o
|
||||
|
||||
RPC_SVC_OBJ = librpc/gen_ndr/srv_srvsvc.o rpc_server/srv_srvsvc_nt.o
|
||||
RPC_SVC_OBJ = rpc_server/srv_srvsvc.o rpc_server/srv_srvsvc_nt.o \
|
||||
librpc/gen_ndr/srv_srvsvc.o
|
||||
|
||||
RPC_WKS_OBJ = librpc/gen_ndr/srv_wkssvc.o rpc_server/srv_wkssvc_nt.o
|
||||
|
||||
@ -529,7 +521,7 @@ SMBD_OBJ_SRV = smbd/files.o smbd/chgpasswd.o smbd/connection.o \
|
||||
smbd/reply.o smbd/sesssetup.o smbd/trans2.o smbd/uid.o \
|
||||
smbd/dosmode.o smbd/filename.o smbd/open.o smbd/close.o \
|
||||
smbd/blocking.o smbd/sec_ctx.o smbd/srvstr.o \
|
||||
smbd/vfs.o smbd/statcache.o smbd/seal.o \
|
||||
smbd/vfs.o smbd/statcache.o \
|
||||
smbd/posix_acls.o lib/sysacls.o $(SERVER_MUTEX_OBJ) \
|
||||
smbd/process.o smbd/service.o smbd/error.o \
|
||||
printing/printfsp.o lib/sysquotas.o lib/sysquotas_linux.o \
|
||||
@ -537,7 +529,7 @@ SMBD_OBJ_SRV = smbd/files.o smbd/chgpasswd.o smbd/connection.o \
|
||||
smbd/change_trust_pw.o smbd/fake_file.o \
|
||||
smbd/quotas.o smbd/ntquotas.o $(AFS_OBJ) smbd/msdfs.o \
|
||||
$(AFS_SETTOKEN_OBJ) smbd/aio.o smbd/statvfs.o \
|
||||
smbd/dmapi.o lib/launchd.o smbd/sockinit.o \
|
||||
smbd/dmapi.o \
|
||||
$(MANGLE_OBJ) @VFS_STATIC@
|
||||
|
||||
SMBD_OBJ_BASE = $(PARAM_WITHOUT_REG_OBJ) $(SMBD_OBJ_SRV) $(LIBSMB_OBJ) \
|
||||
@ -630,7 +622,6 @@ RPCCLIENT_OBJ1 = rpcclient/rpcclient.o rpcclient/cmd_lsarpc.o \
|
||||
rpcclient/cmd_dfs.o \
|
||||
rpcclient/cmd_ds.o rpcclient/cmd_echo.o \
|
||||
rpcclient/cmd_shutdown.o rpcclient/cmd_test.o \
|
||||
rpcclient/cmd_unixinfo.o \
|
||||
$(DISPLAY_SEC_OBJ) $(DISPLAY_DSDCINFO_OBJ)
|
||||
|
||||
RPCCLIENT_OBJ = $(RPCCLIENT_OBJ1) \
|
||||
@ -650,11 +641,6 @@ LIBSMBCLIENT_OBJ = libsmb/libsmbclient.o libsmb/libsmb_compat.o \
|
||||
$(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) $(RPC_PARSE_OBJ) \
|
||||
$(SECRETS_OBJ) $(PASSDB_OBJ) $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ)
|
||||
|
||||
CAC_OBJ = $(LIBSMBCLIENT_OBJ) \
|
||||
libmsrpc/libmsrpc.o libmsrpc/libmsrpc_internal.o \
|
||||
libmsrpc/cac_lsarpc.o libmsrpc/cac_winreg.o libmsrpc/cac_samr.o \
|
||||
libmsrpc/cac_svcctl.o
|
||||
|
||||
LIBSMBSHAREMODES_OBJ = libsmb/smb_share_modes.o $(TDB_BASE_OBJ)
|
||||
|
||||
# This shared library is intended for linking with unit test programs
|
||||
@ -680,6 +666,7 @@ CLIENT_OBJ = $(CLIENT_OBJ1) $(PARAM_OBJ) $(LIBSMB_OBJ) \
|
||||
TOOL_OBJ = client/smbctool.o client/clitar.o $(PARAM_OBJ) $(LIBSMB_OBJ) \
|
||||
$(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) \
|
||||
$(READLINE_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ) \
|
||||
$(PASSDB_OBJ) $(SMBLDAP_OBJ) $(GROUPDB_OBJ) $(LDB_OBJ) \
|
||||
$(DISPLAY_SEC_OBJ)
|
||||
|
||||
UTIL_REG_OBJ = lib/util_reg.o
|
||||
@ -827,7 +814,6 @@ SMBFILTER_OBJ = utils/smbfilter.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(SECRETS_OBJ) \
|
||||
$(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ)
|
||||
|
||||
PROTO_OBJ = $(SMBD_OBJ_MAIN) $(LIBNDR_OBJ) $(LIBNDR_GEN_OBJ) \
|
||||
$(RPCCLIENT_NDR_OBJ) \
|
||||
$(SMBD_OBJ_SRV) $(NMBD_OBJ1) $(LIBSMB_OBJ) \
|
||||
$(SMBTORTURE_OBJ1) $(RPCCLIENT_OBJ1) \
|
||||
$(LIBMSRPC_OBJ) \
|
||||
@ -844,7 +830,7 @@ PROTO_OBJ = $(SMBD_OBJ_MAIN) $(LIBNDR_OBJ) $(LIBNDR_GEN_OBJ) \
|
||||
$(IDMAP_OBJ) libsmb/spnego.o $(PASSCHANGE_OBJ) $(RPC_UNIXINFO_OBJ) \
|
||||
$(RPC_NTSVCS_OBJ) $(RPC_INITSHUTDOWN_OBJ) \
|
||||
utils/passwd_util.o $(LIBGPO_OBJ) $(NSS_INFO_OBJ) \
|
||||
$(RPC_EPMAPPER_OBJ) $(DISPLAY_DSDCINFO_OBJ)
|
||||
$(RPCCLIENT_NDR_OBJ) $(DISPLAY_DSDCINFO_OBJ)
|
||||
|
||||
WINBIND_WINS_NSS_OBJ = nsswitch/wins.o $(PARAM_OBJ) \
|
||||
$(LIBSMB_OBJ) $(LIB_NONSMBD_OBJ) $(NSSWINS_OBJ) $(KRBCLIENT_OBJ) $(SECRETS_OBJ)
|
||||
@ -861,7 +847,6 @@ NSS_INFO_OBJ = winbindd/nss_info.o @NSS_INFO_STATIC@
|
||||
|
||||
WINBINDD_OBJ1 = \
|
||||
winbindd/winbindd.o \
|
||||
winbindd/winbindd_sockinit.o \
|
||||
winbindd/winbindd_user.o \
|
||||
winbindd/winbindd_group.o \
|
||||
winbindd/winbindd_util.o \
|
||||
@ -869,19 +854,17 @@ WINBINDD_OBJ1 = \
|
||||
winbindd/winbindd_pam.o \
|
||||
winbindd/winbindd_sid.o \
|
||||
winbindd/winbindd_misc.o \
|
||||
winbindd/winbindd_cm.o \
|
||||
winbindd/winbindd_wins.o \
|
||||
winbindd/winbindd_rpc.o \
|
||||
winbindd/winbindd_cm.o \
|
||||
winbindd/winbindd_wins.o \
|
||||
winbindd/winbindd_rpc.o \
|
||||
winbindd/winbindd_reconnect.o \
|
||||
winbindd/winbindd_ads.o \
|
||||
winbindd/winbindd_ads.o \
|
||||
winbindd/winbindd_passdb.o \
|
||||
winbindd/winbindd_dual.o \
|
||||
winbindd/winbindd_dual.o \
|
||||
winbindd/winbindd_async.o \
|
||||
winbindd/winbindd_creds.o \
|
||||
winbindd/winbindd_cred_cache.o \
|
||||
winbindd/winbindd_ccache_access.o \
|
||||
winbindd/winbindd_idmap.o \
|
||||
winbindd/winbindd_locator.o \
|
||||
auth/token_util.o
|
||||
|
||||
WINBINDD_OBJ = \
|
||||
@ -891,7 +874,7 @@ WINBINDD_OBJ = \
|
||||
$(PROFILE_OBJ) $(SLCACHE_OBJ) $(SMBLDAP_OBJ) \
|
||||
$(SECRETS_OBJ) $(LIBADS_OBJ) $(KRBCLIENT_OBJ) $(POPT_LIB_OBJ) \
|
||||
$(DCUTIL_OBJ) $(IDMAP_OBJ) $(NSS_INFO_OBJ) \
|
||||
$(AFS_OBJ) $(AFS_SETTOKEN_OBJ) lib/launchd.o \
|
||||
$(AFS_OBJ) $(AFS_SETTOKEN_OBJ) \
|
||||
$(LIBADS_SERVER_OBJ) $(SERVER_MUTEX_OBJ) $(LDB_OBJ)
|
||||
|
||||
WBINFO_OBJ = nsswitch/wbinfo.o $(LIBSAMBA_OBJ) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \
|
||||
@ -1067,18 +1050,6 @@ COMPILE_CC_PATH = $(CC) -I. -I$(srcdir) $(PATH_FLAGS) $(FLAGS) $(PICFLAG) -c $<
|
||||
|
||||
COMPILE = $(COMPILE_CC)
|
||||
|
||||
# BEGIN GNU make specific
|
||||
# Rewrite the COMPILE rule to generate dependencies as a side-effect.
|
||||
# This is is actually toolchain-independent, but making use of the dependency
|
||||
# files requires GNU make, so it's pointless to have them otherwise.
|
||||
@ifGNUmake@DEPDIR=.
|
||||
@ifGNUmake@COMPILE_DEPENDS = source=$< object=$@ libtool=no \
|
||||
@ifGNUmake@ tmpdepfile=$(DEPDIR)/$*.TPo depfile=$(DEPDIR)/$*.d \
|
||||
@ifGNUmake@ DEPDIR=$(DEPDIR) @CCDEPMODE@ \
|
||||
@ifGNUmake@ $(srcdir)/depcomp $(COMPILE_CC)
|
||||
@ifGNUmake@COMPILE = $(COMPILE_DEPENDS)
|
||||
# END GNU make specific
|
||||
|
||||
.c.o:
|
||||
@if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \
|
||||
dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi
|
||||
@ -1093,13 +1064,6 @@ COMPILE = $(COMPILE_CC)
|
||||
$(COMPILE_CC) >/dev/null 2>&1
|
||||
@BROKEN_CC@ -mv `echo $@ | sed 's%^.*/%%g'` $@
|
||||
|
||||
# BEGIN GNU make specific
|
||||
# Include all the generated dependency files. The sort is done to
|
||||
# remove duplicates.
|
||||
@ifGNUmake@DEPENDS_OBJ = $(SMBD_SRV_OBJ) $(NET_OBJ) $(WINBINDD_OBJ)
|
||||
@ifGNUmake@-include $(patsubst %.o, %.d, $(sort $(DEPENDS_OBJ)))
|
||||
# END GNU make specific
|
||||
|
||||
PRECOMPILED_HEADER = $(builddir)/include/includes.h.gch
|
||||
|
||||
# this adds support for precompiled headers. To use it, install a snapshot
|
||||
@ -1392,15 +1356,6 @@ bin/libsmbsharemodes.a: $(BINARY_PREREQS) $(LIBSMBSHAREMODES_OBJ)
|
||||
@echo Linking non-shared library $@
|
||||
@-$(AR) -rc $@ $(LIBSMBSHAREMODES_OBJ)
|
||||
|
||||
bin/libmsrpc.@SHLIBEXT@: $(BINARY_PREREQS) $(CAC_OBJ)
|
||||
@echo Linking shared library $@
|
||||
@$(SHLD_DSO) $(CAC_OBJ) $(LDFLAGS) $(LIBS) \
|
||||
@SONAMEFLAG@`basename $@`.$(SONAME_VER)
|
||||
|
||||
bin/libmsrpc.a: $(BINARY_PREREQS) $(CAC_OBJ)
|
||||
@echo Linking non-shared library $@
|
||||
@-$(AR) -rc $@ $(CAC_OBJ)
|
||||
|
||||
# This is probably wrong for anything other than the GNU linker.
|
||||
bin/libbigballofmud.@SHLIBEXT@: $(BINARY_PREREQS) $(LIBBIGBALLOFMUD_OBJ)
|
||||
@echo Linking shared library $@
|
||||
@ -1434,10 +1389,6 @@ bin/librpc_unixinfo.@SHLIBEXT@: $(BINARY_PREREQS) $(RPC_UNIXINFO_OBJ)
|
||||
@echo "Linking $@"
|
||||
@$(SHLD_MODULE) $(RPC_UNIXINFO_OBJ)
|
||||
|
||||
bin/librpc_epmapper.@SHLIBEXT@: $(BINARY_PREREQS) $(RPC_EPMAPPER_OBJ)
|
||||
@echo "Linking $@"
|
||||
@$(SHLD_MODULE) $(RPC_EPMAPPER_OBJ)
|
||||
|
||||
bin/librpc_srvsvc.@SHLIBEXT@: $(BINARY_PREREQS) $(RPC_SVC_OBJ)
|
||||
@echo "Linking $@"
|
||||
@$(SHLD_MODULE) $(RPC_SVC_OBJ)
|
||||
@ -1836,36 +1787,6 @@ installpammodules: $(PAM_MODULES)
|
||||
"$(DESTDIR)/$(PAMMODULESDIR)"; \
|
||||
done
|
||||
|
||||
# Python extensions
|
||||
|
||||
PYTHON_OBJ = $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(LIBSMB_OBJ) $(RPC_PARSE_OBJ) \
|
||||
$(LIBMSRPC_OBJ) $(LIBMSRPC_GEN_OBJ) $(PASSDB_OBJ) $(GROUPDB_OBJ) \
|
||||
$(SECRETS_OBJ) $(KRBCLIENT_OBJ) $(SMBLDAP_OBJ) $(LDB_OBJ)
|
||||
|
||||
python_ext: $(PYTHON_OBJ)
|
||||
@if test -z "$(PYTHON)"; then \
|
||||
echo Use the option --with-python to configure python; \
|
||||
exit 1; \
|
||||
fi
|
||||
PYTHON_OBJS="$(PYTHON_OBJ)" \
|
||||
PYTHON_CFLAGS="$(CFLAGS) $(CPPFLAGS) $(FLAGS)" \
|
||||
LIBS="$(LDFLAGS) $(LIBS) $(PASSDB_LIBS) $(IDMAP_LIBS) $(KRB5LIBS) $(LDAP_LIBS)" \
|
||||
$(PYTHON) python/setup.py build
|
||||
|
||||
python_install: $(PYTHON_OBJ)
|
||||
@if test -z "$(PYTHON)"; then \
|
||||
echo Use the option --with-python to configure python; \
|
||||
exit 1; \
|
||||
fi
|
||||
PYTHON_OBJS="$(PYTHON_OBJ)" \
|
||||
PYTHON_CFLAGS="$(CFLAGS) $(CPPFLAGS)" \
|
||||
LIBS="$(LDFLAGS) $(LIBS)" \
|
||||
$(PYTHON) python/setup.py install --root=$(DESTDIR)
|
||||
|
||||
python_clean:
|
||||
@-if test -n "$(PYTHON)"; then $(PYTHON) python/setup.py clean; fi
|
||||
@-rm -rf build/
|
||||
|
||||
# revert to the previously installed version
|
||||
revert:
|
||||
@$(SHELL) $(srcdir)/script/revert.sh $(SBINDIR) $(SBIN_PROGS)
|
||||
@ -1948,11 +1869,10 @@ uninstallpammodules:
|
||||
# Toplevel clean files
|
||||
TOPFILES=dynconfig.o
|
||||
|
||||
clean: delheaders python_clean
|
||||
clean: delheaders
|
||||
-rm -f $(PRECOMPILED_HEADER)
|
||||
-rm -f core */*~ *~ \
|
||||
*/*.o */*/*.o */*/*/*.o \
|
||||
*/*.d */*/*.d */*/*/*.d \
|
||||
*/*.@SHLIBEXT@ */*/*.@SHLIBEXT@ */*/*/*.@SHLIBEXT@ \
|
||||
$(TOPFILES) $(BIN_PROGS) $(SBIN_PROGS) $(ROOT_SBIN_PROGS) \
|
||||
$(MODULES) $(TORTURE_PROGS) $(LIBSMBCLIENT) $(LIBADDNS) \
|
||||
@ -2099,32 +2019,16 @@ test_pam_modules: pam_modules
|
||||
|| exit 1; \
|
||||
done
|
||||
|
||||
|
||||
SELFTEST = $(PERL) $(samba4srcdir)/selftest/selftest.pl --prefix=${selftest_prefix} \
|
||||
--srcdir="${samba4srcdir}" --bindir=${builddir}/bin --testlist="${srcdir}/script/tests/tests_all.sh|" \
|
||||
--expected-failures=samba3-knownfail --target=samba3 --skip=samba3-skip $(SELFTEST_ARGS)
|
||||
##
|
||||
## Targets for 'make test'
|
||||
##
|
||||
test: all torture timelimit
|
||||
@echo Running Test suite
|
||||
@$(SELFTEST) --socket-wrapper --immediate $(TESTS)
|
||||
|
||||
htmltest: all torture timelimit
|
||||
@echo Running Test suite
|
||||
@$(SELFTEST) --socket-wrapper --format=html --immediate $(TESTS)
|
||||
@sh $(srcdir)/script/tests/selftest.sh ${selftest_prefix}/st all "${smbtorture4_path}"
|
||||
|
||||
valgrindtest: all torture timelimit
|
||||
@echo Running Test suite with valgrind
|
||||
@NMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
|
||||
SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
|
||||
VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/st/valgrind.log" \
|
||||
$(SELFTEST) --immediate --socket-wrapper $(TESTS)
|
||||
|
||||
gdbtest: all torture timelimit
|
||||
SMBD_VALGRIND="xterm -n smbd -e $(srcdir)/script/gdb_run " \
|
||||
$(SELFTEST) --immediate --socket-wrapper $(TESTS)
|
||||
|
||||
testenv: everything
|
||||
$(SELFTEST) --socket-wrapper --testenv
|
||||
|
||||
$(srcdir)/script/tests/selftest.sh ${selftest_prefix}/st all "${smbtorture4_path}"
|
||||
|
@ -1,4 +0,0 @@
|
||||
- Properly map Samba4's dom_sid to Samba3's DOM_SID
|
||||
- Allow building IDL files from within the Samba3 tree
|
||||
- Autogenerate correct headers so generated files don't have to
|
||||
be edited for Samba3
|
@ -25,11 +25,10 @@
|
||||
########################################################
|
||||
SAMBA_VERSION_MAJOR=3
|
||||
SAMBA_VERSION_MINOR=2
|
||||
SAMBA_VERSION_RELEASE=1
|
||||
SAMBA_VERSION_RELEASE=0
|
||||
|
||||
########################################################
|
||||
# If a official release has a serious bug #
|
||||
# a security release will have 'a' sufffix #
|
||||
# Bug fix releases use a letter for the patch revision #
|
||||
# #
|
||||
# so SAMBA's version will be #
|
||||
# <MAJOR>.<MINOR>.<RELEASE><REVISION> #
|
||||
|
@ -149,7 +149,7 @@ struct server_security_state {
|
||||
****************************************************************************/
|
||||
|
||||
static BOOL send_server_keepalive(const struct timeval *now,
|
||||
void *private_data)
|
||||
void *private_data)
|
||||
{
|
||||
struct server_security_state *state = talloc_get_type_abort(
|
||||
private_data, struct server_security_state);
|
||||
@ -231,7 +231,6 @@ static DATA_BLOB auth_get_challenge_server(const struct auth_context *auth_conte
|
||||
*my_private_data =
|
||||
(void *)make_server_security_state(cli);
|
||||
return data_blob_null;
|
||||
|
||||
} else if (cli->secblob.length < 8) {
|
||||
/* We can't do much if we don't get a full challenge */
|
||||
DEBUG(2,("make_auth_info_server: Didn't receive a full challenge from server\n"));
|
||||
@ -240,7 +239,7 @@ static DATA_BLOB auth_get_challenge_server(const struct auth_context *auth_conte
|
||||
}
|
||||
|
||||
if (!(*my_private_data = (void *)make_server_security_state(cli))) {
|
||||
return data_blob_null;
|
||||
return data_blob(NULL,0);
|
||||
}
|
||||
|
||||
/* The return must be allocated on the caller's mem_ctx, as our own will be
|
||||
@ -258,7 +257,7 @@ static DATA_BLOB auth_get_challenge_server(const struct auth_context *auth_conte
|
||||
****************************************************************************/
|
||||
|
||||
static NTSTATUS check_smbserver_security(const struct auth_context *auth_context,
|
||||
void *private_data,
|
||||
void *my_private_data,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
const auth_usersupplied_info *user_info,
|
||||
auth_serversupplied_info **server_info)
|
||||
@ -270,12 +269,8 @@ static NTSTATUS check_smbserver_security(const struct auth_context *auth_context
|
||||
static BOOL bad_password_server = False;
|
||||
NTSTATUS nt_status = NT_STATUS_NOT_IMPLEMENTED;
|
||||
BOOL locally_made_cli = False;
|
||||
struct server_security_state *state;
|
||||
|
||||
state = talloc_get_type_abort(
|
||||
private_data, struct server_security_state);
|
||||
|
||||
cli = state->cli;
|
||||
cli = (struct cli_state *)my_private_data;
|
||||
|
||||
if (cli) {
|
||||
} else {
|
||||
|
@ -1,51 +0,0 @@
|
||||
#!/bin/sh
|
||||
###############################################################################
|
||||
#
|
||||
# Written by Igor Mammedov (niallain@gmail.com)
|
||||
# Modified by Steve French <sfrench@samba.org>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
###############################################################################
|
||||
#
|
||||
# linux-cifs-client dns name resolver helper
|
||||
# called by cifs kernel module upcall to key API to resolve server name
|
||||
# to IP when module connects to DFS link. We may eventually make this
|
||||
# C code, but this is a good starting point.
|
||||
# You should have appropriate kernel and keyutils installed.
|
||||
# CIFS DFS Support will require Linux kernel module
|
||||
# cifs.ko version 1.48 or later.
|
||||
#
|
||||
# Consult the CIFS client users guide for more details
|
||||
# http://www.samba.org/samba/ftp/cifs-cvs/linux-cifs-client-guide.pdf
|
||||
#
|
||||
# Put the following string in /etc/request-key.conf without comment sign :)
|
||||
# create cifs_resolver * * /sbin/cifs_resolver.sh %k %d %S
|
||||
#
|
||||
# Put this script into /sbin directory
|
||||
# Call: /sbin/cifs_resolver.sh <keyid> <desc> <session-keyring>
|
||||
#
|
||||
# <desc> - is server name to resolve
|
||||
#
|
||||
|
||||
status=0
|
||||
{
|
||||
echo "cifs_resolver: resolving: $2"
|
||||
|
||||
DATAA=`/usr/bin/host $2`
|
||||
status=$?
|
||||
|
||||
if [ "x$status" != "x0" ]; then
|
||||
echo "cifs_resolver: failed to resolve: $2"
|
||||
exit $status
|
||||
else
|
||||
DATAA=`echo "$DATAA" | sed 's/.*has address //'`
|
||||
echo "cifs_resolver: resolved: $2 to $DATAA"
|
||||
keyctl instantiate $1 "$DATAA" $3 || exit 1
|
||||
fi
|
||||
# if you want to debug the upcall, replace /dev/null (below) with ttyS0 or file
|
||||
} >&/dev/null
|
||||
exit 0
|
@ -1823,54 +1823,6 @@ static int cmd_open(void)
|
||||
/****************************************************************************
|
||||
****************************************************************************/
|
||||
|
||||
static int cmd_posix_encrypt(void)
|
||||
{
|
||||
NTSTATUS status;
|
||||
|
||||
if (cli->use_kerberos) {
|
||||
status = cli_gss_smb_encryption_start(cli);
|
||||
} else {
|
||||
fstring buf;
|
||||
fstring domain;
|
||||
fstring user;
|
||||
fstring password;
|
||||
|
||||
if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
|
||||
d_printf("posix_encrypt domain user password\n");
|
||||
return 1;
|
||||
}
|
||||
fstrcpy(domain,buf);
|
||||
|
||||
if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
|
||||
d_printf("posix_encrypt domain user password\n");
|
||||
return 1;
|
||||
}
|
||||
fstrcpy(user,buf);
|
||||
|
||||
if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
|
||||
d_printf("posix_encrypt domain user password\n");
|
||||
return 1;
|
||||
}
|
||||
fstrcpy(password,buf);
|
||||
|
||||
status = cli_raw_ntlm_smb_encryption_start(cli,
|
||||
user,
|
||||
password,
|
||||
domain);
|
||||
}
|
||||
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
d_printf("posix_encrypt failed with error %s\n", nt_errstr(status));
|
||||
} else {
|
||||
d_printf("encryption on\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
****************************************************************************/
|
||||
|
||||
static int cmd_posix_open(void)
|
||||
{
|
||||
pstring mask;
|
||||
@ -3072,12 +3024,10 @@ static BOOL browse_host_rpc(BOOL sort)
|
||||
NTSTATUS status;
|
||||
struct rpc_pipe_client *pipe_hnd;
|
||||
TALLOC_CTX *mem_ctx;
|
||||
uint32 enum_hnd = 0;
|
||||
struct srvsvc_NetShareCtr1 ctr1;
|
||||
union srvsvc_NetShareCtr ctr;
|
||||
ENUM_HND enum_hnd;
|
||||
WERROR werr;
|
||||
SRV_SHARE_INFO_CTR ctr;
|
||||
int i;
|
||||
uint32 level;
|
||||
uint32 numentries;
|
||||
|
||||
mem_ctx = talloc_new(NULL);
|
||||
if (mem_ctx == NULL) {
|
||||
@ -3085,6 +3035,8 @@ static BOOL browse_host_rpc(BOOL sort)
|
||||
return False;
|
||||
}
|
||||
|
||||
init_enum_hnd(&enum_hnd, 0);
|
||||
|
||||
pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SRVSVC, &status);
|
||||
|
||||
if (pipe_hnd == NULL) {
|
||||
@ -3094,23 +3046,23 @@ static BOOL browse_host_rpc(BOOL sort)
|
||||
return False;
|
||||
}
|
||||
|
||||
ZERO_STRUCT(ctr1);
|
||||
level = 1;
|
||||
ctr.ctr1 = &ctr1;
|
||||
werr = rpccli_srvsvc_net_share_enum(pipe_hnd, mem_ctx, 1, &ctr,
|
||||
0xffffffff, &enum_hnd);
|
||||
|
||||
status = rpccli_srvsvc_NetShareEnum(pipe_hnd, mem_ctx, "", &level,
|
||||
&ctr, 0xffffffff, &numentries,
|
||||
&enum_hnd);
|
||||
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
if (!W_ERROR_IS_OK(werr)) {
|
||||
TALLOC_FREE(mem_ctx);
|
||||
cli_rpc_pipe_close(pipe_hnd);
|
||||
return False;
|
||||
}
|
||||
|
||||
for (i=0; i<numentries; i++) {
|
||||
struct srvsvc_NetShareInfo1 *info = &ctr.ctr1->array[i];
|
||||
browse_fn(info->name, info->type, info->comment, NULL);
|
||||
for (i=0; i<ctr.num_entries; i++) {
|
||||
SRV_SHARE_INFO_1 *info = &ctr.share.info1[i];
|
||||
char *name, *comment;
|
||||
name = rpcstr_pull_unistr2_talloc(
|
||||
mem_ctx, &info->info_1_str.uni_netname);
|
||||
comment = rpcstr_pull_unistr2_talloc(
|
||||
mem_ctx, &info->info_1_str.uni_remark);
|
||||
browse_fn(name, info->info_1.type, comment, NULL);
|
||||
}
|
||||
|
||||
TALLOC_FREE(mem_ctx);
|
||||
@ -3322,7 +3274,6 @@ static struct
|
||||
{"newer",cmd_newer,"<file> only mget files newer than the specified local file",{COMPL_LOCAL,COMPL_NONE}},
|
||||
{"open",cmd_open,"<mask> open a file",{COMPL_REMOTE,COMPL_NONE}},
|
||||
{"posix", cmd_posix, "turn on all POSIX capabilities", {COMPL_REMOTE,COMPL_NONE}},
|
||||
{"posix_encrypt",cmd_posix_encrypt,"<domain> <user> <password> start up transport encryption",{COMPL_REMOTE,COMPL_NONE}},
|
||||
{"posix_open",cmd_posix_open,"<name> 0<mode> open_flags mode open a file using POSIX interface",{COMPL_REMOTE,COMPL_NONE}},
|
||||
{"posix_mkdir",cmd_posix_mkdir,"<name> 0<mode> creates a directory using POSIX interface",{COMPL_REMOTE,COMPL_NONE}},
|
||||
{"posix_rmdir",cmd_posix_rmdir,"<name> removes a directory using POSIX interface",{COMPL_REMOTE,COMPL_NONE}},
|
||||
@ -3719,12 +3670,12 @@ static void readline_callback(void)
|
||||
timeout.tv_usec = 0;
|
||||
sys_select_intr(cli->fd+1,&fds,NULL,NULL,&timeout);
|
||||
|
||||
/* We deliberately use cli_receive_smb_return_keepalive instead of
|
||||
/* We deliberately use receive_smb instead of
|
||||
client_receive_smb as we want to receive
|
||||
session keepalives and then drop them here.
|
||||
*/
|
||||
if (FD_ISSET(cli->fd,&fds)) {
|
||||
if (!cli_receive_smb_return_keepalive(cli)) {
|
||||
if (!receive_smb(cli->fd,cli->inbuf,0)) {
|
||||
DEBUG(0, ("Read from server failed, maybe it closed the "
|
||||
"connection\n"));
|
||||
return;
|
||||
|
@ -426,7 +426,7 @@ static int parse_options(char ** optionsp, int * filesys_flags)
|
||||
} else if (strncmp(data, "ip", 2) == 0) {
|
||||
if (!value || !*value) {
|
||||
printf("target ip address argument missing");
|
||||
} else if (strnlen(value, INET6_ADDRSTRLEN) < INET6_ADDRSTRLEN) {
|
||||
} else if (strnlen(value, 35) < 35) {
|
||||
if(verboseflag)
|
||||
printf("ip address %s override specified\n",value);
|
||||
got_ip = 1;
|
||||
|
@ -293,10 +293,6 @@ AC_SUBST(INSTALLLIBCMD_SH)
|
||||
AC_SUBST(INSTALLLIBCMD_A)
|
||||
AC_SUBST(UNINSTALLLIBCMD_SH)
|
||||
AC_SUBST(UNINSTALLLIBCMD_A)
|
||||
AC_SUBST(INSTALL_LIBMSRPC)
|
||||
AC_SUBST(UNINSTALL_LIBMSRPC)
|
||||
AC_SUBST(LIBMSRPC_SHARED)
|
||||
AC_SUBST(LIBMSRPC)
|
||||
AC_SUBST(INSTALL_LIBADDNS)
|
||||
AC_SUBST(UNINSTALL_LIBADDNS)
|
||||
AC_SUBST(LIBADDNS_SHARED)
|
||||
@ -373,7 +369,7 @@ AC_SUBST(SWAT_INSTALL_TARGETS)
|
||||
|
||||
#################################################
|
||||
# set prefix for 'make test'
|
||||
selftest_prefix="./st"
|
||||
selftest_prefix="./"
|
||||
AC_SUBST(selftest_prefix)
|
||||
AC_ARG_WITH(selftest-prefix,
|
||||
[ --with-selftest-prefix=DIR The prefix where make test will be runned ($selftest_prefix)],
|
||||
@ -387,59 +383,21 @@ AC_ARG_WITH(selftest-prefix,
|
||||
esac
|
||||
])
|
||||
|
||||
AC_ARG_ENABLE(launchd,
|
||||
[ --enable-launchd Support running under launchd (default=auto)])
|
||||
|
||||
if test x"$enable_launchd" != x"no" ; then
|
||||
AC_CACHE_CHECK([whether to include launchd support],
|
||||
samba_cv_launchd_support,
|
||||
[
|
||||
AC_TRY_COMPILE(
|
||||
[
|
||||
#include <launch.h>
|
||||
],
|
||||
[
|
||||
launchd_msg(NULL);
|
||||
launchd_data_get_fd(NULL);
|
||||
],
|
||||
samba_cv_launchd_support=yes,
|
||||
samba_cv_launchd_support=no)
|
||||
])
|
||||
|
||||
if test x"$samba_cv_launchd_support" = x"yes" ; then
|
||||
AC_DEFINE(WITH_LAUNCHD_SUPPORT, 1,
|
||||
[Whether launchd support should be enabled])
|
||||
else
|
||||
if test x"$enable_launchd" = x"yes" ; then
|
||||
AC_ERROR(launchd support is not available)
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
#################################################
|
||||
# set path of samba4's smbtorture
|
||||
samba4srcdir=""
|
||||
AC_SUBST(samba4srcdir)
|
||||
AC_ARG_WITH(samba4srcdir,
|
||||
[ --with-samba4srcdir=PATH The path to a samba4 source directorhy for make test (none)],
|
||||
smbtorture4_path=""
|
||||
AC_SUBST(smbtorture4_path)
|
||||
AC_ARG_WITH(smbtorture4_path,
|
||||
[ --with-smbtorture4-path=PATH The path to a samba4 smbtorture for make test (none)],
|
||||
[ case "$withval" in
|
||||
yes|no)
|
||||
AC_MSG_ERROR([--with-samba4srcdir should take a path])
|
||||
AC_MSG_ERROR([--with-smbtorture4-path should take a path])
|
||||
;;
|
||||
* )
|
||||
if test -z "$withval" -a ! -f $withval; then
|
||||
AC_MSG_ERROR(['$withval' does not exist!])
|
||||
smbtorture4_path="$withval"
|
||||
if test -z "$smbtorture4_path" -a ! -f $smbtorture4_path; then
|
||||
AC_MSG_ERROR(['$smbtorture_path' does not exist!])
|
||||
fi
|
||||
|
||||
if test -f "$withval/selftest/selftest.pl"; then
|
||||
samba4srcdir="$withval"
|
||||
else
|
||||
if test -f "$withval/source/selftest/selftest.pl"; then
|
||||
samba4srcdir="$withval/source"
|
||||
else
|
||||
AC_MSG_ERROR([unable to find selftest.pl in '$withval'!])
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
])
|
||||
@ -657,41 +615,7 @@ if test x"$SMB_BUILD_CC_NEGATIVE_ENUM_VALUES" != x"yes"; then
|
||||
PIDL_ARGS="$PIDL_ARGS --uint-enums"
|
||||
fi
|
||||
|
||||
############################################
|
||||
# Check whether we can do automatic dependency tracking
|
||||
|
||||
m4_include(m4/substnot.m4)
|
||||
m4_include(m4/cond.m4)
|
||||
m4_include(m4/make.m4)
|
||||
m4_include(m4/depout.m4)
|
||||
m4_include(m4/lead-dot.m4)
|
||||
m4_include(m4/check_gnu_make.m4)
|
||||
m4_include(m4/depend.m4)
|
||||
|
||||
# Using the dependency files requires GNU make until someone adds support
|
||||
# for Makefile includes for other make implementations. Note that
|
||||
# CHECK_GNU_MAKE() can find a non-default make.
|
||||
CHECK_GNU_MAKE()
|
||||
if test "x$_cv_gnu_make_command" != "x" -a \
|
||||
x`which make` = x`which "$_cv_gnu_make_command"` ; then
|
||||
AC_SUBST(MAKE, $_cv_gnu_make_command)
|
||||
else
|
||||
# If GNU make is not the default, don't enable GNU-isms because we can't
|
||||
# guarantee that GNU make will actually be the make that is invoked.
|
||||
ifGNUmake='#'
|
||||
fi
|
||||
|
||||
AM_DEP_TRACK()
|
||||
_AM_DEPENDENCIES(CC)
|
||||
|
||||
# As per vl, disable dependency tracking by default until we don't need
|
||||
# to use "make proto' -- jpeach
|
||||
if test "x$enable_dependency_tracking" != xyes; then
|
||||
ifGNUmake='#'
|
||||
fi
|
||||
|
||||
############################################
|
||||
# Figure out the flags to support named structure initializers
|
||||
dnl Figure out the flags to support named structure initializers
|
||||
|
||||
LIBREPLACE_C99_STRUCT_INIT([],[AC_MSG_ERROR([c99 structure initializer are not supported])])
|
||||
|
||||
@ -741,7 +665,7 @@ AC_SUBST(DYNEXP)
|
||||
|
||||
dnl Add modules that have to be built by default here
|
||||
dnl These have to be built static:
|
||||
default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_winreg rpc_initshutdown rpc_lsa_ds rpc_wkssvc rpc_svcctl2 rpc_ntsvcs rpc_net rpc_netdfs rpc_srvsvc rpc_spoolss rpc_eventlog2 rpc_unixinfo rpc_epmapper auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default nss_info_template"
|
||||
default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_winreg rpc_initshutdown rpc_lsa_ds rpc_wkssvc rpc_svcctl2 rpc_ntsvcs rpc_net rpc_netdfs rpc_srvsvc2 rpc_spoolss rpc_eventlog2 auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default nss_info_template"
|
||||
|
||||
dnl These are preferably build shared, and static if dlopen() is not available
|
||||
default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy charset_CP850 charset_CP437 auth_script vfs_readahead"
|
||||
@ -869,11 +793,11 @@ case "$host_os" in
|
||||
CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
|
||||
AC_TRY_RUN([
|
||||
#include <unistd.h>
|
||||
int main () {
|
||||
main () {
|
||||
#if _LFS64_LARGEFILE == 1
|
||||
return 0;
|
||||
exit(0);
|
||||
#else
|
||||
return 1;
|
||||
exit(1);
|
||||
#endif
|
||||
}], [SINIX_LFS_SUPPORT=yes], [SINIX_LFS_SUPPORT=no], [SINIX_LFS_SUPPORT=cross])
|
||||
CPPFLAGS="$old_CPPFLAGS"
|
||||
@ -888,15 +812,6 @@ return 1;
|
||||
fi
|
||||
;;
|
||||
|
||||
# Systems with LFS support.
|
||||
#
|
||||
gnu* | k*bsd*-gnu)
|
||||
CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
|
||||
AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
|
||||
AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
|
||||
AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
|
||||
;;
|
||||
|
||||
# Tests for linux LFS support. Need kernel 2.4 and glibc2.2 or greater support.
|
||||
#
|
||||
*linux*)
|
||||
@ -908,7 +823,7 @@ return 1;
|
||||
#include <sys/utsname.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
int main() {
|
||||
main() {
|
||||
#if _LFS64_LARGEFILE == 1
|
||||
struct utsname uts;
|
||||
char *release;
|
||||
@ -920,9 +835,9 @@ int main() {
|
||||
int libc_minor = __GLIBC_MINOR__;
|
||||
|
||||
if (libc_major < 2)
|
||||
return 1;
|
||||
exit(1);
|
||||
if (libc_minor < 2)
|
||||
return 1;
|
||||
exit(1);
|
||||
#endif
|
||||
|
||||
/* Ensure this is kernel 2.4 or higher */
|
||||
@ -933,10 +848,10 @@ int main() {
|
||||
minor = atoi(strsep(&release, "."));
|
||||
|
||||
if (major > 2 || (major == 2 && minor > 3))
|
||||
return 0;
|
||||
return 1;
|
||||
exit(0);
|
||||
exit(1);
|
||||
#else
|
||||
return 1;
|
||||
exit(1);
|
||||
#endif
|
||||
}
|
||||
], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
|
||||
@ -957,7 +872,7 @@ int main() {
|
||||
*darwin*)
|
||||
AC_DEFINE(BROKEN_UNICODE_COMPOSE_CHARACTERS, 1, [Does this system use unicode compose characters])
|
||||
|
||||
# Add a system specific charset module.
|
||||
# Add a system specific charset module.
|
||||
default_shared_modules="$default_shared_modules charset_macosxfs"
|
||||
|
||||
;;
|
||||
@ -969,9 +884,9 @@ int main() {
|
||||
#include <unistd.h>
|
||||
main () {
|
||||
#if _LFS64_LARGEFILE == 1
|
||||
return 0;
|
||||
exit(0);
|
||||
#else
|
||||
return 1;
|
||||
exit(1);
|
||||
#endif
|
||||
}], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
|
||||
CPPFLAGS="$old_CPPFLAGS"
|
||||
@ -1210,7 +1125,7 @@ AC_HAVE_DECL(snprintf, [#include <stdio.h>])
|
||||
# nothing until kernel 2.1.44! very dumb.
|
||||
AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
|
||||
AC_TRY_RUN([#include <errno.h>
|
||||
int main() { setresuid(1,1,1); setresuid(2,2,2); return errno==EPERM?0:1;}],
|
||||
main() { setresuid(1,1,1); setresuid(2,2,2); exit(errno==EPERM?0:1);}],
|
||||
samba_cv_have_setresuid=yes,samba_cv_have_setresuid=no,samba_cv_have_setresuid=cross)])
|
||||
if test x"$samba_cv_have_setresuid" = x"yes"; then
|
||||
AC_DEFINE(HAVE_SETRESUID,1,[Whether the system has setresuid])
|
||||
@ -1221,7 +1136,7 @@ fi
|
||||
AC_CACHE_CHECK([for real setresgid],samba_cv_have_setresgid,[
|
||||
AC_TRY_RUN([#include <unistd.h>
|
||||
#include <errno.h>
|
||||
int main() { errno = 0; setresgid(1,1,1); return errno != 0 ? (errno==EPERM ? 0 : 1) : 0;}],
|
||||
main() { errno = 0; setresgid(1,1,1); exit(errno != 0 ? (errno==EPERM ? 0 : 1) : 0);}],
|
||||
samba_cv_have_setresgid=yes,samba_cv_have_setresgid=no,samba_cv_have_setresgid=cross)])
|
||||
if test x"$samba_cv_have_setresgid" = x"yes"; then
|
||||
AC_DEFINE(HAVE_SETRESGID,1,[Whether the system has setresgid])
|
||||
@ -1374,7 +1289,6 @@ AC_CHECK_FUNCS(memalign posix_memalign hstrerror)
|
||||
AC_CHECK_HEADERS(sys/mman.h)
|
||||
# setbuffer, shmget, shm_open are needed for smbtorture
|
||||
AC_CHECK_FUNCS(setbuffer shmget shm_open)
|
||||
AC_CHECK_FUNCS(makecontext getcontext setcontext swapcontext)
|
||||
|
||||
# Find a method of generating a stack trace
|
||||
AC_CHECK_HEADERS(execinfo.h libexc.h libunwind.h)
|
||||
@ -1525,35 +1439,25 @@ AC_DEFINE(HAVE_PRCTL, 1, [Whether prctl is available]),[])
|
||||
#
|
||||
#
|
||||
case "$host_os" in
|
||||
linux*-gnu* | gnu* | k*bsd*-gnu)
|
||||
*linux*)
|
||||
# glibc <= 2.3.2 has a broken getgrouplist
|
||||
AC_CACHE_CHECK([for a broken Linux getgrouplist API],
|
||||
linux_getgrouplist_ok,
|
||||
[
|
||||
AC_TRY_RUN([
|
||||
AC_TRY_RUN([
|
||||
#include <unistd.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
int main() {
|
||||
/* glibc up to 2.3 has a broken getgrouplist */
|
||||
main() {
|
||||
/* glibc up to 2.3 has a broken getgrouplist */
|
||||
#if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
|
||||
int libc_major = __GLIBC__;
|
||||
int libc_minor = __GLIBC_MINOR__;
|
||||
int libc_major = __GLIBC__;
|
||||
int libc_minor = __GLIBC_MINOR__;
|
||||
|
||||
if (libc_major < 2)
|
||||
return 1;
|
||||
if ((libc_major == 2) && (libc_minor <= 3))
|
||||
return 1;
|
||||
if (libc_major < 2)
|
||||
exit(1);
|
||||
if ((libc_major == 2) && (libc_minor <= 3))
|
||||
exit(1);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
],
|
||||
[linux_getgrouplist_ok=yes],
|
||||
[linux_getgrouplist_ok=no],
|
||||
[linux_getgrouplist_ok=cross])
|
||||
])
|
||||
|
||||
exit(0);
|
||||
}
|
||||
], [linux_getgrouplist_ok=yes], [linux_getgrouplist_ok=no])
|
||||
if test x"$linux_getgrouplist_ok" = x"yes"; then
|
||||
AC_DEFINE(HAVE_GETGROUPLIST, 1, [Have good getgrouplist])
|
||||
fi
|
||||
@ -1574,7 +1478,7 @@ if test x$ac_cv_func_stat64 = xno ; then
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
], [struct stat64 st64; return stat64(".",&st64);], [ac_cv_func_stat64=yes])
|
||||
], [struct stat64 st64; exit(stat64(".",&st64));], [ac_cv_func_stat64=yes])
|
||||
AC_MSG_RESULT([$ac_cv_func_stat64])
|
||||
if test x$ac_cv_func_stat64 = xyes ; then
|
||||
AC_DEFINE(HAVE_STAT64,1,[Whether stat64() is available])
|
||||
@ -1588,7 +1492,7 @@ if test x$ac_cv_func_lstat64 = xno ; then
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
], [struct stat64 st64; return lstat64(".",&st64);], [ac_cv_func_lstat64=yes])
|
||||
], [struct stat64 st64; exit(lstat64(".",&st64));], [ac_cv_func_lstat64=yes])
|
||||
AC_MSG_RESULT([$ac_cv_func_lstat64])
|
||||
if test x$ac_cv_func_lstat64 = xyes ; then
|
||||
AC_DEFINE(HAVE_LSTAT64,[Whether lstat64() is available])
|
||||
@ -1602,7 +1506,7 @@ if test x$ac_cv_func_fstat64 = xno ; then
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
], [struct stat64 st64; return fstat64(0,&st64);], [ac_cv_func_fstat64=yes])
|
||||
], [struct stat64 st64; exit(fstat64(0,&st64));], [ac_cv_func_fstat64=yes])
|
||||
AC_MSG_RESULT([$ac_cv_func_fstat64])
|
||||
if test x$ac_cv_func_fstat64 = xyes ; then
|
||||
AC_DEFINE(HAVE_FSTAT64,1,[Whether fstat64() is available])
|
||||
@ -1825,29 +1729,6 @@ EOF
|
||||
fi
|
||||
fi
|
||||
|
||||
#Check if we can enable relro as well
|
||||
if test x"${samba_cv_fpie}" = x"yes"
|
||||
then
|
||||
AC_CACHE_CHECK(for relro, samba_cv_fpie_relro,
|
||||
[
|
||||
cat > conftest.c <<EOF
|
||||
int foo;
|
||||
main () { return 0;}
|
||||
EOF
|
||||
if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -pie -fPIE -Wl,-z,relro -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
|
||||
then
|
||||
samba_cv_fpie_relro=yes
|
||||
else
|
||||
samba_cv_fpie_relro=no
|
||||
fi
|
||||
rm -f conftest*
|
||||
])
|
||||
if test x"${samba_cv_fpie_relro}" = x"yes"
|
||||
then
|
||||
PIE_LDFLAGS="-pie -Wl,-z,relro"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Assume non-shared by default and override below
|
||||
BLDSHARED="false"
|
||||
|
||||
@ -1863,16 +1744,13 @@ DSO_EXPORTS=""
|
||||
|
||||
# this bit needs to be modified for each OS that supports share libs
|
||||
# You need to specify how to create a shared library and
|
||||
# how to compile C code to produce PIC object files
|
||||
# how to compile C code to produce PIC object files
|
||||
|
||||
AC_MSG_CHECKING([ability to build shared libraries])
|
||||
AC_MSG_CHECKING([ability to build shared libraries])
|
||||
|
||||
# and these are for particular systems
|
||||
case "$host_os" in
|
||||
linux*-gnu* | gnu* | k*bsd*-gnu)
|
||||
case "$host_os" in
|
||||
linux*) AC_DEFINE(LINUX,1,[Whether the host os is linux]) ;;
|
||||
esac
|
||||
# and these are for particular systems
|
||||
case "$host_os" in
|
||||
*linux*) AC_DEFINE(LINUX,1,[Whether the host os is linux])
|
||||
BLDSHARED="true"
|
||||
if test "${ac_cv_gnu_ld_no_default_allow_shlib_undefined}" = "yes"; then
|
||||
LDSHFLAGS="-shared -Wl,-Bsymbolic -Wl,--allow-shlib-undefined"
|
||||
@ -2038,20 +1916,21 @@ case "$host_os" in
|
||||
*darwin*) AC_DEFINE(DARWINOS,1,[Whether the host os is Darwin/MacOSX])
|
||||
BLDSHARED="true"
|
||||
LDSHFLAGS="-bundle -flat_namespace -undefined suppress"
|
||||
MODULE_EXPORTS="-exported_symbols_list \$(srcdir)/exports/modules-darwin.syms"
|
||||
SHLIBEXT="dylib"
|
||||
# Since gcc doesn't fail on unrecognised options, the
|
||||
# PIE test incorrectly succeeds. Darwin gcc does not
|
||||
# actually support the PIE stuff.
|
||||
PIE_LDFLAGS=
|
||||
PIE_CFLAGS=
|
||||
MODULE_EXPORTS="-exported_symbols_list \$(srcdir)/exports/modules-darwin.syms"
|
||||
SHLIBEXT="dylib"
|
||||
# Since gcc doesn't fail on unrecognised options, the
|
||||
# PIE test incorrectly succeeds. Darwin gcc does not
|
||||
# actually support the PIE stuff.
|
||||
PIE_LDFLAGS=
|
||||
PIE_CFLAGS=
|
||||
AC_DEFINE(STAT_ST_BLOCKSIZE,512)
|
||||
;;
|
||||
|
||||
*)
|
||||
AC_DEFINE(STAT_ST_BLOCKSIZE,512)
|
||||
;;
|
||||
esac
|
||||
esac
|
||||
|
||||
if test "$enable_shared" != "yes"; then
|
||||
BLDSHARED=false
|
||||
@ -2124,7 +2003,7 @@ AC_DEFINE_UNQUOTED(SHLIBEXT, "$SHLIBEXT", [Shared library extension])
|
||||
|
||||
AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
|
||||
AC_TRY_RUN([#include <stdio.h>
|
||||
int main() { long long x = 1000000; x *= x; return ((x/1000000) == 1000000)? 0: 1; }],
|
||||
main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
|
||||
samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
|
||||
if test x"$samba_cv_have_longlong" = x"yes"; then
|
||||
AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long's])
|
||||
@ -2156,7 +2035,7 @@ fi
|
||||
AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
|
||||
AC_TRY_RUN([#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
int main() { return (sizeof(off_t) == 8) ? 0 : 1; }],
|
||||
main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
|
||||
samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
|
||||
if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
|
||||
AC_DEFINE(SIZEOF_OFF_T,8,[The size of the 'off_t' type])
|
||||
@ -2169,7 +2048,7 @@ AC_TRY_RUN([
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
int main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) return 1; return (lstat64("/dev/null", &st)==0)?0:1; }],
|
||||
main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
|
||||
samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
|
||||
if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
|
||||
AC_DEFINE(HAVE_OFF64_T,1,[Whether off64_t is available])
|
||||
@ -2182,7 +2061,7 @@ AC_TRY_RUN([
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
int main() { return (sizeof(ino_t) == 8) ? 0 : 1; }],
|
||||
main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
|
||||
samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
|
||||
if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
|
||||
AC_DEFINE(SIZEOF_INO_T,8,[The size of the 'ino_t' type])
|
||||
@ -2195,7 +2074,7 @@ AC_TRY_RUN([
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
int main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) return 1; return (lstat64("/dev/null", &st)==0)?0:1; }],
|
||||
main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
|
||||
samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
|
||||
if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
|
||||
AC_DEFINE(HAVE_INO64_T,1,[Whether the 'ino64_t' type is available])
|
||||
@ -2208,7 +2087,7 @@ AC_TRY_RUN([
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
int main() { return (sizeof(dev_t) == 8) ? 0 : 1; }],
|
||||
main() { exit((sizeof(dev_t) == 8) ? 0 : 1); }],
|
||||
samba_cv_SIZEOF_DEV_T=yes,samba_cv_SIZEOF_DEV_T=no,samba_cv_SIZEOF_DEV_T=cross)])
|
||||
if test x"$samba_cv_SIZEOF_DEV_T" = x"yes"; then
|
||||
AC_DEFINE(SIZEOF_DEV_T,8,[The size of the 'dev_t' type])
|
||||
@ -2221,7 +2100,7 @@ AC_TRY_RUN([
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
int main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) return 1; return (lstat64("/dev/null", &st)==0)?0:1; }],
|
||||
main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
|
||||
samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
|
||||
if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
|
||||
AC_DEFINE(HAVE_DEV64_T,1,[Whether the 'dev64_t' type is available])
|
||||
@ -2259,7 +2138,7 @@ AC_TRY_RUN([
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
int main() { dev_t dev; int i = major(dev); return 0; }],
|
||||
main() { dev_t dev; int i = major(dev); return 0; }],
|
||||
samba_cv_HAVE_DEVICE_MAJOR_FN=yes,samba_cv_HAVE_DEVICE_MAJOR_FN=no,samba_cv_HAVE_DEVICE_MAJOR_FN=cross)])
|
||||
if test x"$samba_cv_HAVE_DEVICE_MAJOR_FN" = x"yes"; then
|
||||
AC_DEFINE(HAVE_DEVICE_MAJOR_FN,1,[Whether the major macro for dev_t is available])
|
||||
@ -2271,7 +2150,7 @@ AC_TRY_RUN([
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
int main() { dev_t dev; int i = minor(dev); return 0; }],
|
||||
main() { dev_t dev; int i = minor(dev); return 0; }],
|
||||
samba_cv_HAVE_DEVICE_MINOR_FN=yes,samba_cv_HAVE_DEVICE_MINOR_FN=no,samba_cv_HAVE_DEVICE_MINOR_FN=cross)])
|
||||
if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
|
||||
AC_DEFINE(HAVE_DEVICE_MINOR_FN,1,[Whether the minor macro for dev_t is available])
|
||||
@ -2283,7 +2162,7 @@ AC_TRY_RUN([
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
int main() { dev_t dev = makedev(1,2); return 0; }],
|
||||
main() { dev_t dev = makedev(1,2); return 0; }],
|
||||
samba_cv_HAVE_MAKEDEV=yes,samba_cv_HAVE_MAKEDEV=no,samba_cv_HAVE_MAKEDEV=cross)])
|
||||
if test x"$samba_cv_HAVE_MAKEDEV" = x"yes"; then
|
||||
AC_DEFINE(HAVE_MAKEDEV,1,[Whether the macro for makedev is available])
|
||||
@ -2291,7 +2170,7 @@ fi
|
||||
|
||||
AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
|
||||
AC_TRY_RUN([#include <stdio.h>
|
||||
int main() { char c; c=250; return (c > 0)?0:1; }],
|
||||
main() { char c; c=250; exit((c > 0)?0:1); }],
|
||||
samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
|
||||
if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
|
||||
AC_DEFINE(HAVE_UNSIGNED_CHAR,1,[Whether the 'unsigned char' type is available])
|
||||
@ -2342,12 +2221,12 @@ if test x"$samba_cv_WITH_PROFILE" = x"yes"; then
|
||||
|
||||
AC_LIBTESTFUNC(rt, clock_gettime,
|
||||
[
|
||||
AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
|
||||
[Whether clock_gettime is available])
|
||||
SMB_CHECK_CLOCK_ID(CLOCK_MONOTONIC)
|
||||
SMB_CHECK_CLOCK_ID(CLOCK_PROCESS_CPUTIME_ID)
|
||||
SMB_CHECK_CLOCK_ID(CLOCK_REALTIME)
|
||||
])
|
||||
AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
|
||||
[Whether clock_gettime is available])
|
||||
SMB_CHECK_CLOCK_ID(CLOCK_MONOTONIC)
|
||||
SMB_CHECK_CLOCK_ID(CLOCK_PROCESS_CPUTIME_ID)
|
||||
SMB_CHECK_CLOCK_ID(CLOCK_REALTIME)
|
||||
])
|
||||
|
||||
fi
|
||||
|
||||
@ -2381,18 +2260,18 @@ void foo(const char *format, ...) {
|
||||
va_start(ap, format);
|
||||
len = vsnprintf(buf, 0, format, ap);
|
||||
va_end(ap);
|
||||
if (len != 5) return 1;
|
||||
if (len != 5) exit(1);
|
||||
|
||||
va_start(ap, format);
|
||||
len = vsnprintf(0, 0, format, ap);
|
||||
va_end(ap);
|
||||
if (len != 5) return 1;
|
||||
if (len != 5) exit(1);
|
||||
|
||||
if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) return 1;
|
||||
if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
|
||||
|
||||
return 0;
|
||||
exit(0);
|
||||
}
|
||||
int main() { foo("hello"); }
|
||||
main() { foo("hello"); }
|
||||
],
|
||||
samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
|
||||
if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
|
||||
@ -2402,9 +2281,9 @@ fi
|
||||
AC_CACHE_CHECK([for broken readdir name],samba_cv_HAVE_BROKEN_READDIR_NAME,[
|
||||
AC_TRY_RUN([#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
int main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
|
||||
main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
|
||||
if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
|
||||
di->d_name[0] == 0) return 0; return 1;} ],
|
||||
di->d_name[0] == 0) exit(0); exit(1);} ],
|
||||
samba_cv_HAVE_BROKEN_READDIR_NAME=yes,samba_cv_HAVE_BROKEN_READDIR_NAME=no,samba_cv_HAVE_BROKEN_READDIR_NAME=cross)])
|
||||
if test x"$samba_cv_HAVE_BROKEN_READDIR_NAME" = x"yes"; then
|
||||
AC_DEFINE(HAVE_BROKEN_READDIR_NAME,1,[Whether readdir() returns the wrong name offset])
|
||||
@ -2413,7 +2292,7 @@ fi
|
||||
AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
|
||||
AC_TRY_COMPILE([#include <sys/types.h>
|
||||
#include <utime.h>],
|
||||
[struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; return utime("foo.c",&tbuf);],
|
||||
[struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
|
||||
samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
|
||||
if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
|
||||
AC_DEFINE(HAVE_UTIMBUF,1,[Whether struct utimbuf is available])
|
||||
@ -2745,7 +2624,7 @@ AC_TRY_RUN([
|
||||
#ifndef F_GETLEASE
|
||||
#define F_GETLEASE 1025
|
||||
#endif
|
||||
int main() {
|
||||
main() {
|
||||
int fd = open("/dev/null", O_RDONLY);
|
||||
return fcntl(fd, F_GETLEASE, 0) == -1;
|
||||
}
|
||||
@ -2763,8 +2642,8 @@ AC_TRY_RUN([
|
||||
#ifndef F_NOTIFY
|
||||
#define F_NOTIFY 1026
|
||||
#endif
|
||||
int main() {
|
||||
return fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0;
|
||||
main() {
|
||||
exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
|
||||
}
|
||||
],
|
||||
samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
|
||||
@ -2841,8 +2720,8 @@ AC_TRY_RUN([
|
||||
#define LOCK_MAND 32
|
||||
#define LOCK_READ 64
|
||||
#endif
|
||||
int main() {
|
||||
return flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0;
|
||||
main() {
|
||||
exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
|
||||
}
|
||||
],
|
||||
samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
|
||||
@ -2878,15 +2757,15 @@ if test x"$samba_cv_HAVE_SYS_CAPABILITY_H" = x"yes"; then
|
||||
AC_TRY_RUN([
|
||||
#include <sys/types.h>
|
||||
#include <sys/capability.h>
|
||||
int main() {
|
||||
main() {
|
||||
cap_t cap;
|
||||
cap_value_t vals[1];
|
||||
if (!(cap = cap_get_proc()))
|
||||
return 1;
|
||||
exit(1);
|
||||
vals[0] = CAP_CHOWN;
|
||||
cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
|
||||
cap_set_proc(cap);
|
||||
return 0;
|
||||
exit(0);
|
||||
}],
|
||||
samba_cv_HAVE_POSIX_CAPABILITIES=yes,
|
||||
samba_cv_HAVE_POSIX_CAPABILITIES=no,
|
||||
@ -3008,15 +2887,15 @@ AC_TRY_RUN([#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
int main() {
|
||||
main() {
|
||||
struct stat st;
|
||||
char tpl[20]="/tmp/test.XXXXXX";
|
||||
int fd = mkstemp(tpl);
|
||||
if (fd == -1) return 1;
|
||||
if (fd == -1) exit(1);
|
||||
unlink(tpl);
|
||||
if (fstat(fd, &st) != 0) return 1;
|
||||
if ((st.st_mode & 0777) != 0600) return 1;
|
||||
return 0;
|
||||
if (fstat(fd, &st) != 0) exit(1);
|
||||
if ((st.st_mode & 0777) != 0600) exit(1);
|
||||
exit(0);
|
||||
}],
|
||||
samba_cv_HAVE_SECURE_MKSTEMP=yes,
|
||||
samba_cv_HAVE_SECURE_MKSTEMP=no,
|
||||
@ -3026,12 +2905,7 @@ if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
|
||||
AC_TRY_RUN([
|
||||
#include "${srcdir-.}/lib/replace/test/os2_delete.c"
|
||||
int main(void) {
|
||||
return test_readdir_os2_delete();
|
||||
}
|
||||
],
|
||||
AC_TRY_RUN([#include "${srcdir-.}/tests/os2_delete.c"],
|
||||
[samba_cv_HAVE_BROKEN_READDIR=no],
|
||||
[samba_cv_HAVE_BROKEN_READDIR=yes],
|
||||
[samba_cv_HAVE_BROKEN_READDIR="assuming not"])])
|
||||
@ -3040,10 +2914,7 @@ if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
|
||||
AC_CACHE_CHECK([for replacing readdir],samba_cv_REPLACE_READDIR,[
|
||||
AC_TRY_RUN([
|
||||
#include "${srcdir-.}/lib/repdir.c"
|
||||
#include "${srcdir-.}/lib/replace/test/os2_delete.c"
|
||||
int main(void) {
|
||||
return test_readdir_os2_delete();
|
||||
],
|
||||
#include "${srcdir-.}/tests/os2_delete.c"],
|
||||
samba_cv_REPLACE_READDIR=yes,samba_cv_REPLACE_READDIR=no)])
|
||||
fi
|
||||
|
||||
@ -3336,11 +3207,11 @@ dnl
|
||||
#ifdef HAVE_SYS_FCNTL_H
|
||||
#include <sys/fcntl.h>
|
||||
#endif
|
||||
int main() { struct flock64 fl64;
|
||||
main() { struct flock64 fl64;
|
||||
#if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
|
||||
return 0;
|
||||
exit(0);
|
||||
#else
|
||||
return 1;
|
||||
exit(1);
|
||||
#endif
|
||||
}],
|
||||
samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
|
||||
@ -3421,11 +3292,10 @@ fi
|
||||
AC_CACHE_CHECK([if the realpath function allows a NULL argument],samba_cv_REALPATH_TAKES_NULL,[
|
||||
AC_TRY_RUN([
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
int main() {
|
||||
main() {
|
||||
char *newpath = realpath("/tmp", NULL);
|
||||
return (newpath != NULL) ? 0 : 1;
|
||||
exit ((newpath != NULL) ? 0 : 1);
|
||||
}
|
||||
],
|
||||
samba_cv_REALPATH_TAKES_NULL=yes,samba_cv_REALPATH_TAKES_NULL=no,samba_cv_REALPATH_TAKES_NULL=cross)])
|
||||
@ -3664,12 +3534,6 @@ if test x"$with_ldap_support" != x"no"; then
|
||||
default_shared_modules="$default_shared_modules";
|
||||
SMBLDAP="lib/smbldap.o"
|
||||
SMBLDAPUTIL="lib/smbldap_util.o"
|
||||
if test x"$ac_cv_func_ext_ldap_initialize" != x"yes"; then
|
||||
AC_MSG_WARN(Disabling ldb_ldap support (requires ldap_initialize))
|
||||
else
|
||||
AC_DEFINE(HAVE_LDB_LDAP,1,[Whether ldb_ldap is available])
|
||||
LDBLDAP="lib/ldb/ldb_ldap/ldb_ldap.o"
|
||||
fi
|
||||
with_ldap_support=yes
|
||||
AC_MSG_CHECKING(whether LDAP support is used)
|
||||
AC_MSG_RESULT(yes)
|
||||
@ -4289,7 +4153,7 @@ if test x"$with_ads_support" != x"no"; then
|
||||
samba_cv_HAVE_WRFILE_KEYTAB,[
|
||||
AC_TRY_RUN([
|
||||
#include<krb5.h>
|
||||
int main()
|
||||
main()
|
||||
{
|
||||
krb5_context context;
|
||||
krb5_keytab keytab;
|
||||
@ -4684,15 +4548,15 @@ if test x"${try_pam}" != x"no";then
|
||||
x"$ac_cv_header_pam_pam_modules_h" = x"no" ; then
|
||||
if test x"${try_pam}" = x"yes";then
|
||||
AC_MSG_ERROR([--with-pam=yes but pam_modules.h not found])
|
||||
fi
|
||||
fi
|
||||
create_pam_modules=no
|
||||
fi
|
||||
fi
|
||||
|
||||
if test x"$use_pam" = x"yes"; then
|
||||
AC_DEFINE(WITH_PAM,1,[Whether to include PAM support])
|
||||
AC_DEFINE(WITH_PAM,1,[Whether to include PAM support])
|
||||
AC_DEFINE(HAVE_LIBPAM,1,[Whether libpam is available])
|
||||
AUTH_LIBS="$AUTH_LIBS $PAM_LIBS"
|
||||
with_pam_for_crypt=yes
|
||||
with_pam_for_crypt=yes
|
||||
|
||||
if test x"$create_pam_modules" = x"yes"; then
|
||||
AC_DEFINE(WITH_PAM_MODULES,1,[Whether to include PAM MODULES support])
|
||||
@ -5167,38 +5031,6 @@ if test $enable_static = yes; then
|
||||
UNINSTALLLIBCMD_A="rm -f"
|
||||
fi
|
||||
|
||||
#################################################
|
||||
# should we build libmsrpc?
|
||||
INSTALL_LIBMSRPC=
|
||||
UNINSTALL_LIBMSRPC=
|
||||
LIBMSRPC_SHARED=
|
||||
LIBMSRPC=
|
||||
AC_MSG_CHECKING(whether to build the libmsrpc shared library)
|
||||
AC_ARG_WITH(libmsrpc,
|
||||
[ --with-libmsrpc Build the libmsrpc shared library (default=no unmaintained)],
|
||||
[ case "$withval" in
|
||||
*)
|
||||
AC_MSG_RESULT(no)
|
||||
;;
|
||||
yes)
|
||||
if test $BLDSHARED = true; then
|
||||
LIBMSRPC_SHARED=bin/libmsrpc.$SHLIBEXT
|
||||
LIBMSRPC=libmsrpc
|
||||
AC_MSG_RESULT(yes)
|
||||
else
|
||||
enable_static=yes
|
||||
AC_MSG_RESULT(no shared library support -- will supply static library)
|
||||
fi
|
||||
if test $enable_static = yes; then
|
||||
LIBMSRPC=libmsrpc
|
||||
fi
|
||||
INSTALL_LIBMSRPC=installlibmsrpc
|
||||
UNINSTALL_LIBMSRPC=uninstalllibmsrpc
|
||||
;;
|
||||
esac ]
|
||||
)
|
||||
|
||||
|
||||
#################################################
|
||||
# should we build libaddns?
|
||||
INSTALL_LIBADDNS=
|
||||
@ -5336,7 +5168,7 @@ if test $space = no; then
|
||||
main ()
|
||||
{
|
||||
struct statvfs64 fsd;
|
||||
return statvfs64 (".", &fsd);
|
||||
exit (statvfs64 (".", &fsd));
|
||||
}],
|
||||
fu_cv_sys_stat_statvfs64=yes,
|
||||
fu_cv_sys_stat_statvfs64=no,
|
||||
@ -5389,7 +5221,7 @@ if test $space = no; then
|
||||
{
|
||||
struct statfs fsd;
|
||||
fsd.f_fsize = 0;
|
||||
return statfs (".", &fsd, sizeof (struct statfs));
|
||||
exit (statfs (".", &fsd, sizeof (struct statfs)));
|
||||
}],
|
||||
fu_cv_sys_stat_statfs3_osf1=yes,
|
||||
fu_cv_sys_stat_statfs3_osf1=no,
|
||||
@ -5420,7 +5252,7 @@ member (AIX, 4.3BSD)])
|
||||
{
|
||||
struct statfs fsd;
|
||||
fsd.f_bsize = 0;
|
||||
return statfs (".", &fsd);
|
||||
exit (statfs (".", &fsd));
|
||||
}],
|
||||
fu_cv_sys_stat_statfs2_bsize=yes,
|
||||
fu_cv_sys_stat_statfs2_bsize=no,
|
||||
@ -5441,7 +5273,7 @@ if test $space = no; then
|
||||
main ()
|
||||
{
|
||||
struct statfs fsd;
|
||||
return statfs (".", &fsd, sizeof fsd, 0);
|
||||
exit (statfs (".", &fsd, sizeof fsd, 0));
|
||||
}],
|
||||
fu_cv_sys_stat_statfs4=yes,
|
||||
fu_cv_sys_stat_statfs4=no,
|
||||
@ -5469,7 +5301,7 @@ member (4.4BSD and NetBSD)])
|
||||
{
|
||||
struct statfs fsd;
|
||||
fsd.f_fsize = 0;
|
||||
return statfs (".", &fsd);
|
||||
exit (statfs (".", &fsd));
|
||||
}],
|
||||
fu_cv_sys_stat_statfs2_fsize=yes,
|
||||
fu_cv_sys_stat_statfs2_fsize=no,
|
||||
@ -5500,7 +5332,7 @@ if test $space = no; then
|
||||
struct fs_data fsd;
|
||||
/* Ultrix's statfs returns 1 for success,
|
||||
0 for not mounted, -1 for failure. */
|
||||
return statfs (".", &fsd) != 1;
|
||||
exit (statfs (".", &fsd) != 1);
|
||||
}],
|
||||
fu_cv_sys_stat_fs_data=yes,
|
||||
fu_cv_sys_stat_fs_data=no,
|
||||
@ -5816,7 +5648,7 @@ AC_ARG_WITH(sendfile-support,
|
||||
AC_MSG_RESULT(yes);
|
||||
|
||||
case "$host_os" in
|
||||
linux*-gnu* | gnu* | k*bsd*-gnu)
|
||||
*linux*)
|
||||
AC_CACHE_CHECK([for linux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
|
||||
AC_TRY_LINK([#include <sys/sendfile.h>],
|
||||
[\
|
||||
@ -6065,7 +5897,6 @@ samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
|
||||
|
||||
AC_CACHE_CHECK([for Linux readahead],
|
||||
samba_cv_HAVE_LINUX_READAHEAD,[
|
||||
|
||||
AC_TRY_LINK([
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
@ -6123,11 +5954,11 @@ NSSSONAMEVERSIONSUFFIX=""
|
||||
WINBIND_NSS_PTHREAD=""
|
||||
|
||||
case "$host_os" in
|
||||
linux*-gnu* | gnu* | k*bsd*-gnu)
|
||||
*linux*)
|
||||
NSSSONAMEVERSIONSUFFIX=".2"
|
||||
WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_linux.o"
|
||||
;;
|
||||
freebsd5*|*freebsd[[6-9]]*)
|
||||
*freebsd[[5-9]]*)
|
||||
# FreeBSD winbind client is implemented as a wrapper around
|
||||
# the Linux version.
|
||||
NSSSONAMEVERSIONSUFFIX=".1"
|
||||
@ -6282,6 +6113,7 @@ if test x"$samba_cv_HAVE_PEERCRED" = x"yes"; then
|
||||
AC_DEFINE(HAVE_PEERCRED,1,[Whether we can use SO_PEERCRED to get socket credentials])
|
||||
fi
|
||||
|
||||
|
||||
#################################################
|
||||
# Check to see if we should use the included popt
|
||||
|
||||
@ -6310,7 +6142,7 @@ if test x"$INCLUDED_POPT" = x"yes"; then
|
||||
FLAGS1="-I\$(srcdir)/popt"
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
BUILD_POPT=""
|
||||
BUILD_POPT=""
|
||||
POPTLIBS="-lpopt"
|
||||
fi
|
||||
AC_SUBST(BUILD_POPT)
|
||||
@ -6354,35 +6186,6 @@ AC_SUBST(FLAGS1)
|
||||
|
||||
|
||||
|
||||
#################################################
|
||||
# Check if the user wants Python
|
||||
|
||||
# At the moment, you can use this to set which Python binary to link
|
||||
# against. (Libraries built for Python2.2 can't be used by 2.1,
|
||||
# though they can coexist in different directories.) In the future
|
||||
# this might make the Python stuff be built by default.
|
||||
|
||||
# Defaulting python breaks the clean target if python isn't installed
|
||||
|
||||
PYTHON=
|
||||
|
||||
AC_ARG_WITH(python,
|
||||
[ --with-python=PYTHONNAME build Python libraries],
|
||||
[ case "${withval-python}" in
|
||||
yes)
|
||||
PYTHON=python
|
||||
EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS python_ext"
|
||||
;;
|
||||
no)
|
||||
PYTHON=
|
||||
;;
|
||||
*)
|
||||
PYTHON=${withval-python}
|
||||
;;
|
||||
esac ])
|
||||
AC_SUBST(PYTHON)
|
||||
|
||||
|
||||
# Checks for the vfs_fileid module
|
||||
# Start
|
||||
AC_CHECK_FUNC(getmntent)
|
||||
@ -6431,7 +6234,7 @@ done
|
||||
|
||||
dnl Always built these modules static
|
||||
MODULE_rpc_spoolss=STATIC
|
||||
MODULE_rpc_srvsvc=STATIC
|
||||
MODULE_rpc_srvsvc2=STATIC
|
||||
MODULE_idmap_tdb=STATIC
|
||||
MODULE_idmap_passdb=STATIC
|
||||
MODULE_idmap_nss=STATIC
|
||||
@ -6472,13 +6275,11 @@ SMB_MODULE(rpc_svcctl2, \$(RPC_SVCCTL_OBJ), "bin/librpc_svcctl2.$SHLIBEXT", RPC)
|
||||
SMB_MODULE(rpc_ntsvcs, \$(RPC_NTSVCS_OBJ), "bin/librpc_ntsvcs.$SHLIBEXT", RPC)
|
||||
SMB_MODULE(rpc_net, \$(RPC_NETLOG_OBJ), "bin/librpc_NETLOGON.$SHLIBEXT", RPC)
|
||||
SMB_MODULE(rpc_netdfs, \$(RPC_DFS_OBJ), "bin/librpc_netdfs.$SHLIBEXT", RPC)
|
||||
SMB_MODULE(rpc_srvsvc, \$(RPC_SVC_OBJ), "bin/librpc_srvsvc.$SHLIBEXT", RPC)
|
||||
SMB_MODULE(rpc_srvsvc2, \$(RPC_SVC_OBJ), "bin/librpc_svcsvc2.$SHLIBEXT", RPC)
|
||||
SMB_MODULE(rpc_spoolss, \$(RPC_SPOOLSS_OBJ), "bin/librpc_spoolss.$SHLIBEXT", RPC)
|
||||
SMB_MODULE(rpc_eventlog2, \$(RPC_EVENTLOG_OBJ), "bin/librpc_eventlog2.$SHLIBEXT", RPC)
|
||||
SMB_MODULE(rpc_samr, \$(RPC_SAMR_OBJ), "bin/librpc_samr.$SHLIBEXT", RPC)
|
||||
SMB_MODULE(rpc_rpcecho, \$(RPC_ECHO_OBJ), "bin/librpc_echo.$SHLIBEXT", RPC)
|
||||
SMB_MODULE(rpc_unixinfo, \$(RPC_UNIXINFO_OBJ), "bin/librpc_unixinfo.$SHLIBEXT", RPC)
|
||||
SMB_MODULE(rpc_epmapper, \$(RPC_EPMAPPER_OBJ), "bin/librpc_epmapper.$SHLIBEXT", RPC)
|
||||
SMB_MODULE(rpc_rpcecho, \$(RPC_ECHO_OBJ), "bin/librpc_rpcecho.$SHLIBEXT", RPC)
|
||||
SMB_SUBSYSTEM(RPC,smbd/server.o)
|
||||
|
||||
SMB_MODULE(idmap_ldap, winbindd/idmap_ldap.o, "bin/ldap.$SHLIBEXT", IDMAP)
|
||||
@ -6532,7 +6333,6 @@ SMB_MODULE(vfs_cacheprime, \$(VFS_CACHEPRIME_OBJ), "bin/cacheprime.$SHLIBEXT", V
|
||||
SMB_MODULE(vfs_prealloc, \$(VFS_PREALLOC_OBJ), "bin/prealloc.$SHLIBEXT", VFS)
|
||||
SMB_MODULE(vfs_commit, \$(VFS_COMMIT_OBJ), "bin/commit.$SHLIBEXT", VFS)
|
||||
SMB_MODULE(vfs_gpfs, \$(VFS_GPFS_OBJ), "bin/gpfs.$SHLIBEXT", VFS)
|
||||
SMB_MODULE(vfs_notify_fam, \$(VFS_NOTIFY_FAM_OBJ), "bin/notify_fam.$SHLIBEXT", VFS)
|
||||
SMB_MODULE(vfs_readahead, \$(VFS_READAHEAD_OBJ), "bin/readahead.$SHLIBEXT", VFS)
|
||||
SMB_MODULE(vfs_fileid, \$(VFS_FILEID_OBJ), "bin/fileid.$SHLIBEXT", VFS)
|
||||
|
||||
@ -6556,9 +6356,7 @@ if test x"$RUN_FROM_BUILD_FARM" = x"yes"; then
|
||||
AC_DEFINE(ENABLE_BUILD_FARM_HACKS, 1, [Defined if running in the build farm])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
SELFTEST_ARGS="$SELFTEST_ARGS --skip=samba3-skip-nobuildfarm"
|
||||
fi
|
||||
AC_SUBST(SELFTEST_ARGS)
|
||||
|
||||
#################################################
|
||||
# check for bad librt/libpthread interactions
|
||||
|
582
source3/depcomp
582
source3/depcomp
@ -1,582 +0,0 @@
|
||||
#! /bin/sh
|
||||
# depcomp - compile a program generating dependencies as side-effects
|
||||
|
||||
scriptversion=2006-10-15.18
|
||||
|
||||
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software
|
||||
# Foundation, Inc.
|
||||
|
||||
# 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, 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Run PROGRAMS ARGS to compile a file, generating dependencies
|
||||
as side-effects.
|
||||
|
||||
Environment variables:
|
||||
depmode Dependency tracking mode.
|
||||
source Source file read by `PROGRAMS ARGS'.
|
||||
object Object file output by `PROGRAMS ARGS'.
|
||||
DEPDIR directory where to store dependencies.
|
||||
depfile Dependency file to output.
|
||||
tmpdepfile Temporary file to use when outputing dependencies.
|
||||
libtool Whether libtool is used (yes/no).
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "depcomp $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
|
||||
echo "depcomp: Variables source, object and depmode must be set" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
|
||||
depfile=${depfile-`echo "$object" |
|
||||
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
|
||||
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
|
||||
|
||||
rm -f "$tmpdepfile"
|
||||
|
||||
# Some modes work just like other modes, but use different flags. We
|
||||
# parameterize here, but still list the modes in the big case below,
|
||||
# to make depend.m4 easier to write. Note that we *cannot* use a case
|
||||
# here, because this file can only contain one case statement.
|
||||
if test "$depmode" = hp; then
|
||||
# HP compiler uses -M and no extra arg.
|
||||
gccflag=-M
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
if test "$depmode" = dashXmstdout; then
|
||||
# This is just like dashmstdout with a different argument.
|
||||
dashmflag=-xM
|
||||
depmode=dashmstdout
|
||||
fi
|
||||
|
||||
case "$depmode" in
|
||||
gcc3)
|
||||
## gcc 3 implements dependency tracking that does exactly what
|
||||
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
|
||||
## it if -MD -MP comes after the -MF stuff. Hmm.
|
||||
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
|
||||
## the command line argument order; so add the flags where they
|
||||
## appear in depend2.am. Note that the slowdown incurred here
|
||||
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
|
||||
*) set fnord "$@" "$arg" ;;
|
||||
esac
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
done
|
||||
"$@"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
mv "$tmpdepfile" "$depfile"
|
||||
;;
|
||||
|
||||
gcc)
|
||||
## There are various ways to get dependency output from gcc. Here's
|
||||
## why we pick this rather obscure method:
|
||||
## - Don't want to use -MD because we'd like the dependencies to end
|
||||
## up in a subdir. Having to rename by hand is ugly.
|
||||
## (We might end up doing this anyway to support other compilers.)
|
||||
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
|
||||
## -MM, not -M (despite what the docs say).
|
||||
## - Using -M directly means running the compiler twice (even worse
|
||||
## than renaming).
|
||||
if test -z "$gccflag"; then
|
||||
gccflag=-MD,
|
||||
fi
|
||||
"$@" -Wp,"$gccflag$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
|
||||
## The second -e expression handles DOS-style file names with drive letters.
|
||||
sed -e 's/^[^:]*: / /' \
|
||||
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
|
||||
## This next piece of magic avoids the `deleted header file' problem.
|
||||
## The problem is that when a header file which appears in a .P file
|
||||
## is deleted, the dependency causes make to die (because there is
|
||||
## typically no way to rebuild the header). We avoid this by adding
|
||||
## dummy dependencies for each header file. Too bad gcc doesn't do
|
||||
## this for us directly.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" |
|
||||
## Some versions of gcc put a space before the `:'. On the theory
|
||||
## that the space means something, we add a space to the output as
|
||||
## well.
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
sgi)
|
||||
if test "$libtool" = yes; then
|
||||
"$@" "-Wp,-MDupdate,$tmpdepfile"
|
||||
else
|
||||
"$@" -MDupdate "$tmpdepfile"
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
|
||||
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
|
||||
echo "$object : \\" > "$depfile"
|
||||
|
||||
# Clip off the initial element (the dependent). Don't try to be
|
||||
# clever and replace this with sed code, as IRIX sed won't handle
|
||||
# lines with more than a fixed number of characters (4096 in
|
||||
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
|
||||
# the IRIX cc adds comments like `#:fec' to the end of the
|
||||
# dependency line.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
|
||||
tr '
|
||||
' ' ' >> $depfile
|
||||
echo >> $depfile
|
||||
|
||||
# The second pass generates a dummy entry for each header file.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
|
||||
>> $depfile
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
aix)
|
||||
# The C for AIX Compiler uses -M and outputs the dependencies
|
||||
# in a .u file. In older versions, this file always lives in the
|
||||
# current directory. Also, the AIX compiler puts `$object:' at the
|
||||
# start of each line; $object doesn't have directory information.
|
||||
# Version 6 uses the directory in both cases.
|
||||
stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
|
||||
tmpdepfile="$stripped.u"
|
||||
if test "$libtool" = yes; then
|
||||
"$@" -Wc,-M
|
||||
else
|
||||
"$@" -M
|
||||
fi
|
||||
stat=$?
|
||||
|
||||
if test -f "$tmpdepfile"; then :
|
||||
else
|
||||
stripped=`echo "$stripped" | sed 's,^.*/,,'`
|
||||
tmpdepfile="$stripped.u"
|
||||
fi
|
||||
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
if test -f "$tmpdepfile"; then
|
||||
outname="$stripped.o"
|
||||
# Each line is of the form `foo.o: dependent.h'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
|
||||
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
icc)
|
||||
# Intel's C compiler understands `-MD -MF file'. However on
|
||||
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
|
||||
# ICC 7.0 will fill foo.d with something like
|
||||
# foo.o: sub/foo.c
|
||||
# foo.o: sub/foo.h
|
||||
# which is wrong. We want:
|
||||
# sub/foo.o: sub/foo.c
|
||||
# sub/foo.o: sub/foo.h
|
||||
# sub/foo.c:
|
||||
# sub/foo.h:
|
||||
# ICC 7.1 will output
|
||||
# foo.o: sub/foo.c sub/foo.h
|
||||
# and will wrap long lines using \ :
|
||||
# foo.o: sub/foo.c ... \
|
||||
# sub/foo.h ... \
|
||||
# ...
|
||||
|
||||
"$@" -MD -MF "$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
# Each line is of the form `foo.o: dependent.h',
|
||||
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
|
||||
sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp2)
|
||||
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
|
||||
# compilers, which have integrated preprocessors. The correct option
|
||||
# to use with these is +Maked; it writes dependencies to a file named
|
||||
# 'foo.d', which lands next to the object file, wherever that
|
||||
# happens to be.
|
||||
# Much of this is similar to the tru64 case; see comments there.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir.libs/$base.d
|
||||
"$@" -Wc,+Maked
|
||||
else
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
"$@" +Maked
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
|
||||
# Add `dependent.h:' lines.
|
||||
sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile" "$tmpdepfile2"
|
||||
;;
|
||||
|
||||
tru64)
|
||||
# The Tru64 compiler uses -MD to generate dependencies as a side
|
||||
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
|
||||
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
|
||||
# dependencies in `foo.d' instead, so we check for that too.
|
||||
# Subdirectories are respected.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
|
||||
if test "$libtool" = yes; then
|
||||
# With Tru64 cc, shared objects can also be used to make a
|
||||
# static library. This mechanism is used in libtool 1.4 series to
|
||||
# handle both shared and static libraries in a single compilation.
|
||||
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
|
||||
#
|
||||
# With libtool 1.5 this exception was removed, and libtool now
|
||||
# generates 2 separate objects for the 2 libraries. These two
|
||||
# compilations output dependencies in $dir.libs/$base.o.d and
|
||||
# in $dir$base.o.d. We have to check for both files, because
|
||||
# one of the two compilations can be disabled. We should prefer
|
||||
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
|
||||
# automatically cleaned when .libs/ is deleted, while ignoring
|
||||
# the former would cause a distcleancheck panic.
|
||||
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
|
||||
tmpdepfile2=$dir$base.o.d # libtool 1.5
|
||||
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
|
||||
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
|
||||
"$@" -Wc,-MD
|
||||
else
|
||||
tmpdepfile1=$dir$base.o.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
tmpdepfile3=$dir$base.d
|
||||
tmpdepfile4=$dir$base.d
|
||||
"$@" -MD
|
||||
fi
|
||||
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
|
||||
# That's a tab and a space in the [].
|
||||
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
#nosideeffect)
|
||||
# This comment above is used by automake to tell side-effect
|
||||
# dependency tracking mechanisms from slower ones.
|
||||
|
||||
dashmstdout)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout, regardless of -o.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test $1 != '--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove `-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
test -z "$dashmflag" && dashmflag=-M
|
||||
# Require at least two characters before searching for `:'
|
||||
# in the target name. This is to cope with DOS-style filenames:
|
||||
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
|
||||
"$@" $dashmflag |
|
||||
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" | \
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
dashXmstdout)
|
||||
# This case only exists to satisfy depend.m4. It is never actually
|
||||
# run, as this mode is specially recognized in the preamble.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
makedepend)
|
||||
"$@" || exit $?
|
||||
# Remove any Libtool call
|
||||
if test "$libtool" = yes; then
|
||||
while test $1 != '--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
# X makedepend
|
||||
shift
|
||||
cleared=no
|
||||
for arg in "$@"; do
|
||||
case $cleared in
|
||||
no)
|
||||
set ""; shift
|
||||
cleared=yes ;;
|
||||
esac
|
||||
case "$arg" in
|
||||
-D*|-I*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
# Strip any option that makedepend may not understand. Remove
|
||||
# the object too, otherwise makedepend will parse it as a source file.
|
||||
-*|$object)
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
esac
|
||||
done
|
||||
obj_suffix="`echo $object | sed 's/^.*\././'`"
|
||||
touch "$tmpdepfile"
|
||||
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
sed '1,2d' "$tmpdepfile" | tr ' ' '
|
||||
' | \
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile" "$tmpdepfile".bak
|
||||
;;
|
||||
|
||||
cpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test $1 != '--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove `-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
"$@" -E |
|
||||
sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
|
||||
sed '$ s: \\$::' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
cat < "$tmpdepfile" >> "$depfile"
|
||||
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvisualcpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout, regardless of -o,
|
||||
# because we must use -o when running libtool.
|
||||
"$@" || exit $?
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case "$arg" in
|
||||
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
|
||||
set fnord "$@"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
"$@" -E |
|
||||
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
|
||||
echo " " >> "$depfile"
|
||||
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
none)
|
||||
exec "$@"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown depmode $depmode" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-end: "$"
|
||||
# End:
|
@ -82,9 +82,6 @@ ADS_STATUS ads_search_retry_extended_dn_ranged(ADS_STRUCT *ads, TALLOC_CTX *mem_
|
||||
enum ads_extended_dn_flags flags,
|
||||
char ***strings,
|
||||
size_t *num_strings);
|
||||
BOOL ads_get_dn_from_extended_dn(TALLOC_CTX *mem_ctx,
|
||||
const char *extended_dn,
|
||||
char **dn);
|
||||
ADS_STATUS ads_search_retry_sid(ADS_STRUCT *ads, LDAPMessage **res,
|
||||
const DOM_SID *sid,
|
||||
const char **attrs);
|
||||
|
@ -78,28 +78,6 @@ struct rpc_pipe_client {
|
||||
struct dcinfo *dc;
|
||||
};
|
||||
|
||||
/* Transport encryption state. */
|
||||
enum smb_trans_enc_type { SMB_TRANS_ENC_NTLM, SMB_TRANS_ENC_GSS };
|
||||
|
||||
#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
|
||||
struct smb_tran_enc_state_gss {
|
||||
gss_ctx_id_t gss_ctx;
|
||||
gss_cred_id_t creds;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct smb_trans_enc_state {
|
||||
enum smb_trans_enc_type smb_enc_type;
|
||||
uint16 enc_ctx_num;
|
||||
BOOL enc_on;
|
||||
union {
|
||||
NTLMSSP_STATE *ntlmssp_state;
|
||||
#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
|
||||
struct smb_tran_enc_state_gss *gss_state;
|
||||
#endif
|
||||
} s;
|
||||
};
|
||||
|
||||
struct cli_state {
|
||||
int port;
|
||||
int fd;
|
||||
@ -159,8 +137,6 @@ struct cli_state {
|
||||
|
||||
smb_sign_info sign_info;
|
||||
|
||||
struct smb_trans_enc_state *trans_enc_state; /* Setup if we're encrypting SMB's. */
|
||||
|
||||
/* the session key for this CLI, outside
|
||||
any per-pipe authenticaion */
|
||||
DATA_BLOB user_session_key;
|
||||
|
0
source3/include/dcerpc.h
Normal file
0
source3/include/dcerpc.h
Normal file
@ -680,6 +680,7 @@ typedef int BOOL;
|
||||
#include "reg_objects.h"
|
||||
#include "reg_db.h"
|
||||
#include "rpc_samr.h"
|
||||
#include "rpc_srvsvc.h"
|
||||
#include "rpc_spoolss.h"
|
||||
#include "rpc_eventlog.h"
|
||||
#include "rpc_ds.h"
|
||||
@ -782,6 +783,8 @@ enum flush_reason_enum {
|
||||
#include "librpc/gen_ndr/srv_svcctl.h"
|
||||
#include "librpc/gen_ndr/srv_lsa.h"
|
||||
#include "librpc/gen_ndr/srv_eventlog.h"
|
||||
#include "librpc/gen_ndr/srv_winreg.h"
|
||||
#include "librpc/gen_ndr/srv_initshutdown.h"
|
||||
|
||||
/***** automatically generated prototypes *****/
|
||||
#ifndef NO_PROTO_H
|
||||
|
@ -233,9 +233,17 @@ typedef struct pipes_struct {
|
||||
struct dcinfo *dc; /* Keeps the creds data from netlogon. */
|
||||
|
||||
/*
|
||||
* Credentials used for the pipe operations
|
||||
* Windows user info.
|
||||
*/
|
||||
fstring user_name;
|
||||
fstring domain;
|
||||
fstring wks;
|
||||
|
||||
/*
|
||||
* Unix user name and credentials used when a pipe is authenticated.
|
||||
*/
|
||||
|
||||
fstring pipe_user_name;
|
||||
struct current_user pipe_user;
|
||||
DATA_BLOB session_key;
|
||||
|
||||
|
@ -64,7 +64,7 @@
|
||||
#define FSCTL_DISMOUNT_VOLUME
|
||||
#define FSCTL_GET_NTFS_FILE_RECORD
|
||||
#define FSCTL_ALLOW_EXTENDED_DASD_IO
|
||||
#define FSCTL_RECALL_FILE 0x00090117
|
||||
#define FSCTL_RECALL_FILE
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -49,17 +49,6 @@ struct user_auth_info {
|
||||
int signing_state;
|
||||
};
|
||||
|
||||
enum smb_server_mode {
|
||||
/* Daemonize and manage our own sockets */
|
||||
SERVER_MODE_DAEMON,
|
||||
/* Don't daemonize or manage sockets */
|
||||
SERVER_MODE_INETD,
|
||||
/* Don't daemonize, but do manage sockets */
|
||||
SERVER_MODE_FOREGROUND,
|
||||
/* Run in the foreground, log to stdout, don't fork children */
|
||||
SERVER_MODE_INTERACTIVE
|
||||
};
|
||||
|
||||
extern struct user_auth_info cmdline_auth_info;
|
||||
|
||||
#endif /* _POPT_COMMON_H */
|
||||
|
@ -23,15 +23,14 @@
|
||||
/* autogenerated client stubs */
|
||||
|
||||
#include "librpc/gen_ndr/cli_echo.h"
|
||||
#include "librpc/gen_ndr/cli_unixinfo.h"
|
||||
#include "librpc/gen_ndr/cli_epmapper.h"
|
||||
#include "librpc/gen_ndr/cli_dfs.h"
|
||||
#include "librpc/gen_ndr/cli_lsa.h"
|
||||
#include "librpc/gen_ndr/cli_srvsvc.h"
|
||||
#include "librpc/gen_ndr/cli_svcctl.h"
|
||||
#include "librpc/gen_ndr/cli_winreg.h"
|
||||
#include "librpc/gen_ndr/cli_initshutdown.h"
|
||||
#include "librpc/gen_ndr/cli_wkssvc.h"
|
||||
#include "librpc/gen_ndr/cli_eventlog.h"
|
||||
#include "librpc/gen_ndr/cli_dfs.h"
|
||||
#include "librpc/gen_ndr/cli_initshutdown.h"
|
||||
#include "librpc/gen_ndr/cli_winreg.h"
|
||||
#include "librpc/gen_ndr/cli_srvsvc.h"
|
||||
|
||||
/* macro to expand cookie-cutter code in cli_xxx() using rpc_api_pipe_req() */
|
||||
|
||||
|
@ -92,6 +92,10 @@ enum unistr2_term_codes { UNI_FLAGS_NONE = 0, UNI_STR_TERMINATE = 1, UNI_MAXLEN_
|
||||
**********************************************************************/
|
||||
|
||||
typedef struct policy_handle POLICY_HND;
|
||||
typedef struct {
|
||||
uint32 ptr_hnd; /* pointer to enumeration handle */
|
||||
uint32 handle; /* enumeration handle */
|
||||
} ENUM_HND;
|
||||
|
||||
#define OUR_HANDLE(hnd) (((hnd)==NULL) ? "NULL" :\
|
||||
( IVAL((hnd)->uuid.node,2) == (uint32)sys_getpid() ? "OURS" : \
|
||||
|
@ -45,6 +45,11 @@
|
||||
#define NET_DSR_GETDCNAMEEX2 0x22
|
||||
#define NET_SAMLOGON_EX 0x27
|
||||
|
||||
/* Secure Channel types. used in NetrServerAuthenticate negotiation */
|
||||
#define SEC_CHAN_WKSTA 2
|
||||
#define SEC_CHAN_DOMAIN 4
|
||||
#define SEC_CHAN_BDC 6
|
||||
|
||||
/* Returned delta types */
|
||||
#define SAM_DELTA_DOMAIN_INFO 0x01
|
||||
#define SAM_DELTA_GROUP_INFO 0x02
|
||||
@ -63,6 +68,11 @@
|
||||
#define SAM_DELTA_DELETE_USER 0x15
|
||||
#define SAM_DELTA_MODIFIED_COUNT 0x16
|
||||
|
||||
/* SAM database types */
|
||||
#define SAM_DATABASE_DOMAIN 0x00 /* Domain users and groups */
|
||||
#define SAM_DATABASE_BUILTIN 0x01 /* BUILTIN users and groups */
|
||||
#define SAM_DATABASE_PRIVS 0x02 /* Privileges */
|
||||
|
||||
/* flags use when sending a NETLOGON_CONTROL request */
|
||||
|
||||
#define NETLOGON_CONTROL_SYNC 0x2
|
||||
|
@ -4,7 +4,7 @@
|
||||
Copyright (C) Andrew Tridgell 1992-2000
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1996-2000
|
||||
Copyright (C) Paul Ashton 1997-2000
|
||||
Copyright (C) Jean François Micouleau 1998-2001
|
||||
Copyright (C) Jean François Micouleau 1998-2001
|
||||
Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002
|
||||
|
||||
|
||||
@ -127,11 +127,11 @@ SamrTestPrivateFunctionsUser
|
||||
#define SAMR_REMOVE_SID_FOREIGN_DOMAIN 0x2d
|
||||
#define SAMR_QUERY_DOMAIN_INFO2 0x2e /* looks like an alias for SAMR_QUERY_DOMAIN_INFO */
|
||||
#define SAMR_UNKNOWN_2f 0x2f
|
||||
#define SAMR_QUERY_DISPINFO2 0x30 /* Alias for SAMR_QUERY_DISPINFO
|
||||
#define SAMR_QUERY_DISPINFO3 0x30 /* Alias for SAMR_QUERY_DISPINFO
|
||||
with info level 3 */
|
||||
#define SAMR_GET_DISPENUM_INDEX2 0x31
|
||||
#define SAMR_UNKNOWN_31 0x31
|
||||
#define SAMR_CREATE_USER 0x32
|
||||
#define SAMR_QUERY_DISPINFO3 0x33 /* Alias for SAMR_QUERY_DISPINFO
|
||||
#define SAMR_QUERY_DISPINFO4 0x33 /* Alias for SAMR_QUERY_DISPINFO
|
||||
with info level 4 */
|
||||
#define SAMR_ADDMULTI_ALIASMEM 0x34
|
||||
|
||||
|
871
source3/include/rpc_srvsvc.h
Normal file
871
source3/include/rpc_srvsvc.h
Normal file
@ -0,0 +1,871 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
SMB parameters and setup
|
||||
Copyright (C) Andrew Tridgell 1992-1997
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1996-1997
|
||||
Copyright (C) Paul Ashton 1997
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _RPC_SRVSVC_H /* _RPC_SRVSVC_H */
|
||||
#define _RPC_SRVSVC_H
|
||||
|
||||
/* srvsvc pipe */
|
||||
#define SRV_NET_CONN_ENUM 0x08
|
||||
#define SRV_NET_FILE_ENUM 0x09
|
||||
#define SRV_NET_FILE_CLOSE 0x0b
|
||||
#define SRV_NET_SESS_ENUM 0x0c
|
||||
#define SRV_NET_SESS_DEL 0x0d
|
||||
#define SRV_NET_SHARE_ADD 0x0e
|
||||
#define SRV_NET_SHARE_ENUM_ALL 0x0f
|
||||
#define SRV_NET_SHARE_GET_INFO 0x10
|
||||
#define SRV_NET_SHARE_SET_INFO 0x11
|
||||
#define SRV_NET_SHARE_DEL 0x12
|
||||
#define SRV_NET_SHARE_DEL_STICKY 0x13
|
||||
#define SRV_NET_SRV_GET_INFO 0x15
|
||||
#define SRV_NET_SRV_SET_INFO 0x16
|
||||
#define SRV_NET_DISK_ENUM 0x17
|
||||
#define SRV_NET_REMOTE_TOD 0x1c
|
||||
#define SRV_NET_NAME_VALIDATE 0x21
|
||||
#define SRV_NET_SHARE_ENUM 0x24
|
||||
#define SRV_NET_FILE_QUERY_SECDESC 0x27
|
||||
#define SRV_NET_FILE_SET_SECDESC 0x28
|
||||
|
||||
#define MAX_SERVER_DISK_ENTRIES 15
|
||||
|
||||
typedef struct disk_info {
|
||||
uint32 unknown;
|
||||
UNISTR3 disk_name;
|
||||
} DISK_INFO;
|
||||
|
||||
typedef struct disk_enum_container {
|
||||
uint32 level;
|
||||
uint32 entries_read;
|
||||
uint32 unknown;
|
||||
uint32 disk_info_ptr;
|
||||
DISK_INFO *disk_info;
|
||||
} DISK_ENUM_CONTAINER;
|
||||
|
||||
typedef struct net_srv_disk_enum {
|
||||
uint32 ptr_srv_name; /* pointer (to server name?) */
|
||||
UNISTR2 uni_srv_name; /* server name */
|
||||
|
||||
DISK_ENUM_CONTAINER disk_enum_ctr;
|
||||
|
||||
uint32 preferred_len; /* preferred maximum length (0xffff ffff) */
|
||||
uint32 total_entries; /* total number of entries */
|
||||
ENUM_HND enum_hnd;
|
||||
WERROR status; /* return status */
|
||||
} SRV_Q_NET_DISK_ENUM, SRV_R_NET_DISK_ENUM;
|
||||
|
||||
/***************************/
|
||||
|
||||
typedef struct {
|
||||
UNISTR2 *servername;
|
||||
UNISTR2 sharename;
|
||||
uint32 type;
|
||||
uint32 flags;
|
||||
WERROR status;
|
||||
} SRV_Q_NET_NAME_VALIDATE;
|
||||
|
||||
typedef struct {
|
||||
WERROR status;
|
||||
} SRV_R_NET_NAME_VALIDATE;
|
||||
|
||||
/***************************/
|
||||
|
||||
/* 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
|
||||
|
||||
typedef struct {
|
||||
UNISTR2 *sharename;
|
||||
} SESS_INFO_0;
|
||||
|
||||
typedef struct {
|
||||
uint32 num_entries_read;
|
||||
uint32 ptr_sess_info;
|
||||
uint32 num_entries_read2;
|
||||
SESS_INFO_0 info_0[MAX_SESS_ENTRIES];
|
||||
} SRV_SESS_INFO_0;
|
||||
|
||||
typedef struct {
|
||||
UNISTR2 *sharename;
|
||||
UNISTR2 *username;
|
||||
uint32 num_opens;
|
||||
uint32 open_time;
|
||||
uint32 idle_time;
|
||||
uint32 user_flags;
|
||||
} SESS_INFO_1;
|
||||
|
||||
typedef struct {
|
||||
uint32 num_entries_read;
|
||||
uint32 ptr_sess_info;
|
||||
uint32 num_entries_read2;
|
||||
SESS_INFO_1 info_1[MAX_SESS_ENTRIES];
|
||||
} SRV_SESS_INFO_1;
|
||||
|
||||
typedef struct {
|
||||
uint32 switch_value;
|
||||
uint32 ptr_sess_ctr;
|
||||
union {
|
||||
SRV_SESS_INFO_0 info0;
|
||||
SRV_SESS_INFO_1 info1;
|
||||
} sess;
|
||||
|
||||
} SRV_SESS_INFO_CTR;
|
||||
|
||||
typedef struct {
|
||||
UNISTR2 *servername;
|
||||
UNISTR2 *qualifier;
|
||||
UNISTR2 *username;
|
||||
uint32 sess_level;
|
||||
SRV_SESS_INFO_CTR *ctr;
|
||||
uint32 preferred_len;
|
||||
ENUM_HND enum_hnd;
|
||||
} SRV_Q_NET_SESS_ENUM;
|
||||
|
||||
typedef struct {
|
||||
uint32 sess_level;
|
||||
SRV_SESS_INFO_CTR *ctr;
|
||||
uint32 total_entries;
|
||||
ENUM_HND enum_hnd;
|
||||
WERROR status;
|
||||
} SRV_R_NET_SESS_ENUM;
|
||||
|
||||
/***************************/
|
||||
|
||||
/* SRV_Q_NET_SESS_DEL */
|
||||
typedef struct q_net_sess_del
|
||||
{
|
||||
uint32 ptr_srv_name; /* pointer (to server name?) */
|
||||
UNISTR2 uni_srv_name; /* server name */
|
||||
|
||||
uint32 ptr_cli_name; /* pointer (to qualifier name) */
|
||||
UNISTR2 uni_cli_name; /* qualifier name "\\qualifier" */
|
||||
|
||||
uint32 ptr_user_name; /* pointer (to user name */
|
||||
UNISTR2 uni_user_name; /* user name */
|
||||
|
||||
} SRV_Q_NET_SESS_DEL;
|
||||
|
||||
/* SRV_R_NET_SESS_DEL */
|
||||
typedef struct r_net_sess_del
|
||||
{
|
||||
WERROR status; /* return status */
|
||||
|
||||
} SRV_R_NET_SESS_DEL;
|
||||
|
||||
/* CONN_INFO_0 (pointers to level 0 connection info strings) */
|
||||
typedef struct ptr_conn_info0
|
||||
{
|
||||
uint32 id; /* connection id. */
|
||||
|
||||
} CONN_INFO_0;
|
||||
|
||||
/* 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
|
||||
|
||||
/* SRV_CONN_INFO_0 */
|
||||
typedef struct srv_conn_info_0_info
|
||||
{
|
||||
uint32 num_entries_read; /* EntriesRead */
|
||||
uint32 ptr_conn_info; /* Buffer */
|
||||
uint32 num_entries_read2; /* EntriesRead */
|
||||
|
||||
CONN_INFO_0 info_0 [MAX_CONN_ENTRIES]; /* connection entry pointers */
|
||||
|
||||
} SRV_CONN_INFO_0;
|
||||
|
||||
/* CONN_INFO_1 (pointers to level 1 connection info strings) */
|
||||
typedef struct ptr_conn_info1
|
||||
{
|
||||
uint32 id; /* connection id */
|
||||
uint32 type; /* 0x3 */
|
||||
uint32 num_opens;
|
||||
uint32 num_users;
|
||||
uint32 open_time;
|
||||
|
||||
uint32 ptr_usr_name; /* pointer to user name. */
|
||||
uint32 ptr_net_name; /* pointer to network name (e.g IPC$). */
|
||||
|
||||
} CONN_INFO_1;
|
||||
|
||||
/* CONN_INFO_1_STR (level 1 connection info strings) */
|
||||
typedef struct str_conn_info1
|
||||
{
|
||||
UNISTR2 uni_usr_name; /* unicode string of user */
|
||||
UNISTR2 uni_net_name; /* unicode string of name */
|
||||
|
||||
} CONN_INFO_1_STR;
|
||||
|
||||
/* SRV_CONN_INFO_1 */
|
||||
typedef struct srv_conn_info_1_info
|
||||
{
|
||||
uint32 num_entries_read; /* EntriesRead */
|
||||
uint32 ptr_conn_info; /* Buffer */
|
||||
uint32 num_entries_read2; /* EntriesRead */
|
||||
|
||||
CONN_INFO_1 info_1 [MAX_CONN_ENTRIES]; /* connection entry pointers */
|
||||
CONN_INFO_1_STR info_1_str[MAX_CONN_ENTRIES]; /* connection entry strings */
|
||||
|
||||
} SRV_CONN_INFO_1;
|
||||
|
||||
/* SRV_CONN_INFO_CTR */
|
||||
typedef struct srv_conn_info_ctr_info
|
||||
{
|
||||
uint32 switch_value; /* switch value */
|
||||
uint32 ptr_conn_ctr; /* pointer to conn info union */
|
||||
union
|
||||
{
|
||||
SRV_CONN_INFO_0 info0; /* connection info level 0 */
|
||||
SRV_CONN_INFO_1 info1; /* connection info level 1 */
|
||||
|
||||
} conn;
|
||||
|
||||
} SRV_CONN_INFO_CTR;
|
||||
|
||||
|
||||
/* SRV_Q_NET_CONN_ENUM */
|
||||
typedef struct q_net_conn_enum_info
|
||||
{
|
||||
uint32 ptr_srv_name; /* pointer (to server name) */
|
||||
UNISTR2 uni_srv_name; /* server name "\\server" */
|
||||
|
||||
uint32 ptr_qual_name; /* pointer (to qualifier name) */
|
||||
UNISTR2 uni_qual_name; /* qualifier name "\\qualifier" */
|
||||
|
||||
uint32 conn_level; /* connection level */
|
||||
|
||||
SRV_CONN_INFO_CTR *ctr;
|
||||
|
||||
uint32 preferred_len; /* preferred maximum length (0xffff ffff) */
|
||||
ENUM_HND enum_hnd;
|
||||
|
||||
} SRV_Q_NET_CONN_ENUM;
|
||||
|
||||
/* SRV_R_NET_CONN_ENUM */
|
||||
typedef struct r_net_conn_enum_info
|
||||
{
|
||||
uint32 conn_level; /* share level */
|
||||
|
||||
SRV_CONN_INFO_CTR *ctr;
|
||||
|
||||
uint32 total_entries; /* total number of entries */
|
||||
ENUM_HND enum_hnd;
|
||||
|
||||
WERROR status; /* return status */
|
||||
|
||||
} SRV_R_NET_CONN_ENUM;
|
||||
|
||||
/* SH_INFO_0 */
|
||||
typedef struct ptr_share_info0
|
||||
{
|
||||
uint32 ptr_netname; /* pointer to net name. */
|
||||
} SH_INFO_0;
|
||||
|
||||
/* SH_INFO_0_STR (level 0 share info strings) */
|
||||
typedef struct str_share_info0
|
||||
{
|
||||
SH_INFO_0 *ptrs;
|
||||
|
||||
UNISTR2 uni_netname; /* unicode string of net name */
|
||||
|
||||
} SH_INFO_0_STR;
|
||||
|
||||
/* SRV_SHARE_INFO_0 */
|
||||
typedef struct share_info_0_info
|
||||
{
|
||||
SH_INFO_0 info_0;
|
||||
SH_INFO_0_STR info_0_str;
|
||||
|
||||
} SRV_SHARE_INFO_0;
|
||||
|
||||
/* SH_INFO_1 (pointers to level 1 share info strings) */
|
||||
typedef struct ptr_share_info1
|
||||
{
|
||||
uint32 ptr_netname; /* pointer to net name. */
|
||||
uint32 type; /* ipc, print, disk ... */
|
||||
uint32 ptr_remark; /* pointer to comment. */
|
||||
|
||||
} SH_INFO_1;
|
||||
|
||||
/* SH_INFO_1_STR (level 1 share info strings) */
|
||||
typedef struct str_share_info1
|
||||
{
|
||||
SH_INFO_1 *ptrs;
|
||||
|
||||
UNISTR2 uni_netname; /* unicode string of net name */
|
||||
UNISTR2 uni_remark; /* unicode string of comment */
|
||||
|
||||
} SH_INFO_1_STR;
|
||||
|
||||
/* SRV_SHARE_INFO_1 */
|
||||
typedef struct share_info_1_info
|
||||
{
|
||||
SH_INFO_1 info_1;
|
||||
SH_INFO_1_STR info_1_str;
|
||||
|
||||
} SRV_SHARE_INFO_1;
|
||||
|
||||
/* SH_INFO_2 (pointers to level 2 share info strings) */
|
||||
typedef struct ptr_share_info2
|
||||
{
|
||||
uint32 ptr_netname; /* pointer to net name. */
|
||||
uint32 type; /* ipc, print, disk ... */
|
||||
uint32 ptr_remark; /* pointer to comment. */
|
||||
uint32 perms; /* permissions */
|
||||
uint32 max_uses; /* maximum uses */
|
||||
uint32 num_uses; /* current uses */
|
||||
uint32 ptr_path; /* pointer to path name */
|
||||
uint32 ptr_passwd; /* pointer to password */
|
||||
|
||||
} SH_INFO_2;
|
||||
|
||||
/* SH_INFO_2_STR (level 2 share info strings) */
|
||||
typedef struct str_share_info2
|
||||
{
|
||||
SH_INFO_2 *ptrs;
|
||||
|
||||
UNISTR2 uni_netname; /* unicode string of net name (e.g NETLOGON) */
|
||||
UNISTR2 uni_remark; /* unicode string of comment (e.g "Logon server share") */
|
||||
UNISTR2 uni_path; /* unicode string of local path (e.g c:\winnt\system32\repl\import\scripts) */
|
||||
UNISTR2 uni_passwd; /* unicode string of password - presumably for share level security (e.g NULL) */
|
||||
|
||||
} SH_INFO_2_STR;
|
||||
|
||||
/* SRV_SHARE_INFO_2 */
|
||||
typedef struct share_info_2_info
|
||||
{
|
||||
SH_INFO_2 info_2;
|
||||
SH_INFO_2_STR info_2_str;
|
||||
|
||||
} SRV_SHARE_INFO_2;
|
||||
|
||||
typedef struct ptr_share_info501
|
||||
{
|
||||
uint32 ptr_netname; /* pointer to net name */
|
||||
uint32 type; /* ipc, print, disk */
|
||||
uint32 ptr_remark; /* pointer to comment */
|
||||
uint32 csc_policy; /* client-side offline caching policy << 4 */
|
||||
} SH_INFO_501;
|
||||
|
||||
typedef struct str_share_info501
|
||||
{
|
||||
UNISTR2 uni_netname; /* unicode string of net name */
|
||||
UNISTR2 uni_remark; /* unicode string of comment */
|
||||
} SH_INFO_501_STR;
|
||||
|
||||
/* SRV_SHARE_INFO_501 */
|
||||
typedef struct share_info_501_info
|
||||
{
|
||||
SH_INFO_501 info_501;
|
||||
SH_INFO_501_STR info_501_str;
|
||||
} SRV_SHARE_INFO_501;
|
||||
|
||||
/* SH_INFO_502 (pointers to level 502 share info strings) */
|
||||
typedef struct ptr_share_info502
|
||||
{
|
||||
uint32 ptr_netname; /* pointer to net name. */
|
||||
uint32 type; /* ipc, print, disk ... */
|
||||
uint32 ptr_remark; /* pointer to comment. */
|
||||
uint32 perms; /* permissions */
|
||||
uint32 max_uses; /* maximum uses */
|
||||
uint32 num_uses; /* current uses */
|
||||
uint32 ptr_path; /* pointer to path name */
|
||||
uint32 ptr_passwd; /* pointer to password */
|
||||
uint32 reserved; /* this holds the space taken by the sd in the rpc packet */
|
||||
uint32 reserved_offset; /* required for _post operation when marshalling */
|
||||
uint32 sd_size; /* size of security descriptor */
|
||||
uint32 ptr_sd; /* pointer to security descriptor */
|
||||
|
||||
} SH_INFO_502;
|
||||
|
||||
/* SH_INFO_502_STR (level 502 share info strings) */
|
||||
typedef struct str_share_info502
|
||||
{
|
||||
SH_INFO_502 *ptrs;
|
||||
|
||||
UNISTR2 uni_netname; /* unicode string of net name (e.g NETLOGON) */
|
||||
UNISTR2 uni_remark; /* unicode string of comment (e.g "Logon server share") */
|
||||
UNISTR2 uni_path; /* unicode string of local path (e.g c:\winnt\system32\repl\import\scripts) */
|
||||
UNISTR2 uni_passwd; /* unicode string of password - presumably for share level security (e.g NULL) */
|
||||
|
||||
uint32 reserved;
|
||||
uint32 sd_size;
|
||||
SEC_DESC *sd;
|
||||
|
||||
} SH_INFO_502_STR;
|
||||
|
||||
/* SRV_SHARE_INFO_502 */
|
||||
typedef struct share_info_502_info
|
||||
{
|
||||
SH_INFO_502 info_502;
|
||||
SH_INFO_502_STR info_502_str;
|
||||
|
||||
} SRV_SHARE_INFO_502;
|
||||
|
||||
typedef struct ptr_share_info1004
|
||||
{
|
||||
uint32 ptr_remark;
|
||||
|
||||
} SH_INFO_1004;
|
||||
|
||||
typedef struct str_share_info1004
|
||||
{
|
||||
SH_INFO_1004 *ptrs;
|
||||
|
||||
UNISTR2 uni_remark;
|
||||
|
||||
} SH_INFO_1004_STR;
|
||||
|
||||
typedef struct ptr_info_1004_info
|
||||
{
|
||||
SH_INFO_1004 info_1004;
|
||||
SH_INFO_1004_STR info_1004_str;
|
||||
} SRV_SHARE_INFO_1004;
|
||||
|
||||
typedef struct share_info_1005_info
|
||||
{
|
||||
uint32 share_info_flags;
|
||||
} SRV_SHARE_INFO_1005;
|
||||
|
||||
typedef struct share_info_1006_info
|
||||
{
|
||||
uint32 max_uses;
|
||||
} SRV_SHARE_INFO_1006;
|
||||
|
||||
typedef struct ptr_share_info1007
|
||||
{
|
||||
uint32 flags;
|
||||
uint32 ptr_AlternateDirectoryName;
|
||||
|
||||
} SH_INFO_1007;
|
||||
|
||||
typedef struct str_share_info1007
|
||||
{
|
||||
SH_INFO_1007 *ptrs;
|
||||
|
||||
UNISTR2 uni_AlternateDirectoryName;
|
||||
|
||||
} SH_INFO_1007_STR;
|
||||
|
||||
typedef struct ptr_info_1007_info
|
||||
{
|
||||
SH_INFO_1007 info_1007;
|
||||
SH_INFO_1007_STR info_1007_str;
|
||||
} SRV_SHARE_INFO_1007;
|
||||
|
||||
/* SRV_SHARE_INFO_1501 */
|
||||
typedef struct share_info_1501_info
|
||||
{
|
||||
SEC_DESC_BUF *sdb;
|
||||
} SRV_SHARE_INFO_1501;
|
||||
|
||||
/* SRV_SHARE_INFO_CTR */
|
||||
typedef struct srv_share_info_ctr_info
|
||||
{
|
||||
uint32 info_level;
|
||||
uint32 switch_value;
|
||||
uint32 ptr_share_info;
|
||||
|
||||
uint32 num_entries;
|
||||
uint32 ptr_entries;
|
||||
uint32 num_entries2;
|
||||
|
||||
union {
|
||||
SRV_SHARE_INFO_0 *info0;
|
||||
SRV_SHARE_INFO_1 *info1; /* share info level 1 */
|
||||
SRV_SHARE_INFO_2 *info2; /* share info level 2 */
|
||||
SRV_SHARE_INFO_501 *info501; /* share info level 501 */
|
||||
SRV_SHARE_INFO_502 *info502; /* share info level 502 */
|
||||
SRV_SHARE_INFO_1004 *info1004;
|
||||
SRV_SHARE_INFO_1005 *info1005;
|
||||
SRV_SHARE_INFO_1006 *info1006;
|
||||
SRV_SHARE_INFO_1007 *info1007;
|
||||
SRV_SHARE_INFO_1501 *info1501;
|
||||
void *info;
|
||||
|
||||
} share;
|
||||
|
||||
} SRV_SHARE_INFO_CTR;
|
||||
|
||||
/* SRV_Q_NET_SHARE_ENUM */
|
||||
typedef struct q_net_share_enum_info
|
||||
{
|
||||
uint32 ptr_srv_name; /* pointer (to server name?) */
|
||||
UNISTR2 uni_srv_name; /* server name */
|
||||
|
||||
SRV_SHARE_INFO_CTR ctr; /* share info container */
|
||||
|
||||
uint32 preferred_len; /* preferred maximum length (0xffff ffff) */
|
||||
|
||||
ENUM_HND enum_hnd;
|
||||
|
||||
} SRV_Q_NET_SHARE_ENUM;
|
||||
|
||||
|
||||
/* SRV_R_NET_SHARE_ENUM */
|
||||
typedef struct r_net_share_enum_info
|
||||
{
|
||||
SRV_SHARE_INFO_CTR ctr; /* share info container */
|
||||
|
||||
uint32 total_entries; /* total number of entries */
|
||||
ENUM_HND enum_hnd;
|
||||
|
||||
WERROR status; /* return status */
|
||||
|
||||
} SRV_R_NET_SHARE_ENUM;
|
||||
|
||||
|
||||
/* SRV_Q_NET_SHARE_GET_INFO */
|
||||
typedef struct q_net_share_get_info_info
|
||||
{
|
||||
uint32 ptr_srv_name;
|
||||
UNISTR2 uni_srv_name;
|
||||
|
||||
UNISTR2 uni_share_name;
|
||||
uint32 info_level;
|
||||
|
||||
} SRV_Q_NET_SHARE_GET_INFO;
|
||||
|
||||
/* SRV_SHARE_INFO */
|
||||
typedef struct srv_share_info {
|
||||
uint32 switch_value;
|
||||
uint32 ptr_share_ctr;
|
||||
|
||||
union {
|
||||
SRV_SHARE_INFO_0 info0;
|
||||
SRV_SHARE_INFO_1 info1;
|
||||
SRV_SHARE_INFO_2 info2;
|
||||
SRV_SHARE_INFO_501 info501;
|
||||
SRV_SHARE_INFO_502 info502;
|
||||
SRV_SHARE_INFO_1004 info1004;
|
||||
SRV_SHARE_INFO_1005 info1005;
|
||||
SRV_SHARE_INFO_1006 info1006;
|
||||
SRV_SHARE_INFO_1007 info1007;
|
||||
SRV_SHARE_INFO_1501 info1501;
|
||||
} share;
|
||||
} SRV_SHARE_INFO;
|
||||
|
||||
/* SRV_R_NET_SHARE_GET_INFO */
|
||||
typedef struct r_net_share_get_info_info
|
||||
{
|
||||
SRV_SHARE_INFO info;
|
||||
WERROR status;
|
||||
|
||||
} SRV_R_NET_SHARE_GET_INFO;
|
||||
|
||||
/* SRV_Q_NET_SHARE_SET_INFO */
|
||||
typedef struct q_net_share_set_info_info
|
||||
{
|
||||
uint32 ptr_srv_name;
|
||||
UNISTR2 uni_srv_name;
|
||||
|
||||
UNISTR2 uni_share_name;
|
||||
uint32 info_level;
|
||||
|
||||
SRV_SHARE_INFO info;
|
||||
|
||||
uint32 ptr_parm_error;
|
||||
uint32 parm_error;
|
||||
|
||||
} SRV_Q_NET_SHARE_SET_INFO;
|
||||
|
||||
/* SRV_R_NET_SHARE_SET_INFO */
|
||||
typedef struct r_net_share_set_info
|
||||
{
|
||||
uint32 ptr_parm_error;
|
||||
uint32 parm_error;
|
||||
|
||||
WERROR status; /* return status */
|
||||
|
||||
} SRV_R_NET_SHARE_SET_INFO;
|
||||
|
||||
/* SRV_Q_NET_SHARE_ADD */
|
||||
typedef struct q_net_share_add
|
||||
{
|
||||
uint32 ptr_srv_name;
|
||||
UNISTR2 uni_srv_name;
|
||||
|
||||
uint32 info_level;
|
||||
|
||||
SRV_SHARE_INFO info;
|
||||
|
||||
uint32 ptr_err_index; /* pointer to error index */
|
||||
uint32 err_index; /* index in info to field in error */
|
||||
|
||||
} SRV_Q_NET_SHARE_ADD;
|
||||
|
||||
/* SRV_R_NET_SHARE_ADD */
|
||||
typedef struct r_net_share_add
|
||||
{
|
||||
|
||||
uint32 ptr_parm_error;
|
||||
uint32 parm_error;
|
||||
|
||||
WERROR status; /* return status */
|
||||
|
||||
} SRV_R_NET_SHARE_ADD;
|
||||
|
||||
/* SRV_Q_NET_SHARE_DEL */
|
||||
typedef struct q_net_share_del
|
||||
{
|
||||
uint32 ptr_srv_name;
|
||||
UNISTR2 uni_srv_name;
|
||||
UNISTR2 uni_share_name;
|
||||
uint32 reserved;
|
||||
|
||||
} SRV_Q_NET_SHARE_DEL;
|
||||
|
||||
/* SRV_R_NET_SHARE_DEL */
|
||||
typedef struct r_net_share_del
|
||||
{
|
||||
WERROR status; /* return status */
|
||||
|
||||
} SRV_R_NET_SHARE_DEL;
|
||||
|
||||
/***************************/
|
||||
|
||||
typedef struct {
|
||||
uint32 id; /* file index */
|
||||
uint32 perms; /* file permissions. don't know what format */
|
||||
uint32 num_locks; /* file locks */
|
||||
UNISTR2 *path; /* file name */
|
||||
UNISTR2 *user; /* file owner */
|
||||
} FILE_INFO_3;
|
||||
|
||||
typedef struct {
|
||||
uint32 level; /* switch value */
|
||||
uint32 ptr_file_info; /* pointer to file info union */
|
||||
|
||||
uint32 num_entries;
|
||||
uint32 ptr_entries;
|
||||
uint32 num_entries2;
|
||||
union {
|
||||
FILE_INFO_3 *info3;
|
||||
} file;
|
||||
|
||||
} SRV_FILE_INFO_CTR;
|
||||
|
||||
typedef struct {
|
||||
UNISTR2 *servername;
|
||||
UNISTR2 *qualifier;
|
||||
UNISTR2 *username;
|
||||
uint32 level;
|
||||
SRV_FILE_INFO_CTR ctr;
|
||||
uint32 preferred_len; /* preferred maximum length (0xffff ffff) */
|
||||
ENUM_HND enum_hnd;
|
||||
} SRV_Q_NET_FILE_ENUM;
|
||||
|
||||
typedef struct {
|
||||
uint32 level;
|
||||
SRV_FILE_INFO_CTR ctr;
|
||||
uint32 total_entries;
|
||||
ENUM_HND enum_hnd;
|
||||
WERROR status;
|
||||
} SRV_R_NET_FILE_ENUM;
|
||||
|
||||
/* SRV_INFO_100 */
|
||||
typedef struct srv_info_100_info
|
||||
{
|
||||
uint32 platform_id; /* 0x500 */
|
||||
uint32 ptr_name; /* pointer to server name */
|
||||
|
||||
UNISTR2 uni_name; /* server name "server" */
|
||||
|
||||
} SRV_INFO_100;
|
||||
|
||||
/* SRV_INFO_101 */
|
||||
typedef struct srv_info_101_info
|
||||
{
|
||||
uint32 platform_id; /* 0x500 */
|
||||
uint32 ptr_name; /* pointer to server name */
|
||||
uint32 ver_major; /* 0x4 */
|
||||
uint32 ver_minor; /* 0x2 */
|
||||
uint32 srv_type; /* browse etc type */
|
||||
uint32 ptr_comment; /* pointer to server comment */
|
||||
|
||||
UNISTR2 uni_name; /* server name "server" */
|
||||
UNISTR2 uni_comment; /* server comment "samba x.x.x blah" */
|
||||
|
||||
} SRV_INFO_101;
|
||||
|
||||
/* SRV_INFO_102 */
|
||||
typedef struct srv_info_102_info
|
||||
{
|
||||
uint32 platform_id; /* 0x500 */
|
||||
uint32 ptr_name; /* pointer to server name */
|
||||
uint32 ver_major; /* 0x4 */
|
||||
uint32 ver_minor; /* 0x2 */
|
||||
uint32 srv_type; /* browse etc type */
|
||||
uint32 ptr_comment; /* pointer to server comment */
|
||||
uint32 users; /* 0xffff ffff*/
|
||||
uint32 disc; /* 0xf */
|
||||
uint32 hidden; /* 0x0 */
|
||||
uint32 announce; /* 240 */
|
||||
uint32 ann_delta; /* 3000 */
|
||||
uint32 licenses; /* 0 */
|
||||
uint32 ptr_usr_path; /* pointer to user path */
|
||||
|
||||
UNISTR2 uni_name; /* server name "server" */
|
||||
UNISTR2 uni_comment; /* server comment "samba x.x.x blah" */
|
||||
UNISTR2 uni_usr_path; /* "c:\" (eh?) */
|
||||
|
||||
} SRV_INFO_102;
|
||||
|
||||
|
||||
/* SRV_INFO_CTR */
|
||||
typedef struct srv_info_ctr_info
|
||||
{
|
||||
uint32 switch_value; /* switch value */
|
||||
uint32 ptr_srv_ctr; /* pointer to server info */
|
||||
union
|
||||
{
|
||||
SRV_INFO_102 sv102; /* server info level 102 */
|
||||
SRV_INFO_101 sv101; /* server info level 101 */
|
||||
SRV_INFO_100 sv100; /* server info level 100 */
|
||||
|
||||
} srv;
|
||||
|
||||
} SRV_INFO_CTR;
|
||||
|
||||
/* SRV_Q_NET_SRV_GET_INFO */
|
||||
typedef struct q_net_srv_get_info
|
||||
{
|
||||
uint32 ptr_srv_name;
|
||||
UNISTR2 uni_srv_name; /* "\\server" */
|
||||
uint32 switch_value;
|
||||
|
||||
} SRV_Q_NET_SRV_GET_INFO;
|
||||
|
||||
/* SRV_R_NET_SRV_GET_INFO */
|
||||
typedef struct r_net_srv_get_info
|
||||
{
|
||||
SRV_INFO_CTR *ctr;
|
||||
|
||||
WERROR status; /* return status */
|
||||
|
||||
} SRV_R_NET_SRV_GET_INFO;
|
||||
|
||||
/* SRV_Q_NET_SRV_SET_INFO */
|
||||
typedef struct q_net_srv_set_info
|
||||
{
|
||||
uint32 ptr_srv_name;
|
||||
UNISTR2 uni_srv_name; /* "\\server" */
|
||||
uint32 switch_value;
|
||||
|
||||
SRV_INFO_CTR *ctr;
|
||||
|
||||
} SRV_Q_NET_SRV_SET_INFO;
|
||||
|
||||
|
||||
/* SRV_R_NET_SRV_SET_INFO */
|
||||
typedef struct r_net_srv_set_info
|
||||
{
|
||||
uint32 switch_value; /* switch value */
|
||||
|
||||
WERROR status; /* return status */
|
||||
|
||||
} SRV_R_NET_SRV_SET_INFO;
|
||||
|
||||
/* SRV_Q_NET_REMOTE_TOD */
|
||||
typedef struct q_net_remote_tod
|
||||
{
|
||||
uint32 ptr_srv_name;
|
||||
UNISTR2 uni_srv_name; /* "\\server" */
|
||||
|
||||
} SRV_Q_NET_REMOTE_TOD;
|
||||
|
||||
/* TIME_OF_DAY_INFO */
|
||||
typedef struct time_of_day_info
|
||||
{
|
||||
uint32 elapsedt;
|
||||
uint32 msecs;
|
||||
uint32 hours;
|
||||
uint32 mins;
|
||||
uint32 secs;
|
||||
uint32 hunds;
|
||||
uint32 zone;
|
||||
uint32 tintervals;
|
||||
uint32 day;
|
||||
uint32 month;
|
||||
uint32 year;
|
||||
uint32 weekday;
|
||||
|
||||
} TIME_OF_DAY_INFO;
|
||||
|
||||
/* SRV_R_NET_REMOTE_TOD */
|
||||
typedef struct r_net_remote_tod
|
||||
{
|
||||
uint32 ptr_srv_tod; /* pointer to TOD */
|
||||
TIME_OF_DAY_INFO *tod;
|
||||
|
||||
WERROR status; /* return status */
|
||||
|
||||
} SRV_R_NET_REMOTE_TOD;
|
||||
|
||||
/* SRV_Q_NET_FILE_QUERY_SECDESC */
|
||||
typedef struct q_net_file_query_secdesc
|
||||
{
|
||||
uint32 ptr_srv_name;
|
||||
UNISTR2 uni_srv_name;
|
||||
uint32 ptr_qual_name;
|
||||
UNISTR2 uni_qual_name;
|
||||
UNISTR2 uni_file_name;
|
||||
uint32 unknown1;
|
||||
uint32 unknown2;
|
||||
uint32 unknown3;
|
||||
} SRV_Q_NET_FILE_QUERY_SECDESC;
|
||||
|
||||
/* SRV_R_NET_FILE_QUERY_SECDESC */
|
||||
typedef struct r_net_file_query_secdesc
|
||||
{
|
||||
uint32 ptr_response;
|
||||
uint32 size_response;
|
||||
uint32 ptr_secdesc;
|
||||
uint32 size_secdesc;
|
||||
SEC_DESC *sec_desc;
|
||||
WERROR status;
|
||||
} SRV_R_NET_FILE_QUERY_SECDESC;
|
||||
|
||||
/* SRV_Q_NET_FILE_SET_SECDESC */
|
||||
typedef struct q_net_file_set_secdesc
|
||||
{
|
||||
uint32 ptr_srv_name;
|
||||
UNISTR2 uni_srv_name;
|
||||
uint32 ptr_qual_name;
|
||||
UNISTR2 uni_qual_name;
|
||||
UNISTR2 uni_file_name;
|
||||
uint32 sec_info;
|
||||
uint32 size_set;
|
||||
uint32 ptr_secdesc;
|
||||
uint32 size_secdesc;
|
||||
SEC_DESC *sec_desc;
|
||||
} SRV_Q_NET_FILE_SET_SECDESC;
|
||||
|
||||
/* SRV_R_NET_FILE_SET_SECDESC */
|
||||
typedef struct r_net_file_set_secdesc
|
||||
{
|
||||
WERROR status;
|
||||
} SRV_R_NET_FILE_SET_SECDESC;
|
||||
|
||||
|
||||
#endif /* _RPC_SRVSVC_H */
|
@ -78,7 +78,6 @@
|
||||
#define WRITE_ERROR 4 /* This error code can go into the client smb_rw_error. */
|
||||
#define READ_BAD_SIG 5
|
||||
#define DO_NOT_DO_TDIS 6 /* cli_close_connection() check for this when smbfs wants to keep tree connected */
|
||||
#define READ_BAD_DECRYPT 7
|
||||
|
||||
#define DIR_STRUCT_SIZE 43
|
||||
|
||||
@ -186,10 +185,9 @@ typedef uint32 codepoint_t;
|
||||
#define PIPE_NETDFS "\\PIPE\\netdfs"
|
||||
#define PIPE_ECHO "\\PIPE\\rpcecho"
|
||||
#define PIPE_SHUTDOWN "\\PIPE\\initshutdown"
|
||||
#define PIPE_EPMAPPER "\\PIPE\\epmapper"
|
||||
#define PIPE_EPM "\\PIPE\\epmapper"
|
||||
#define PIPE_SVCCTL "\\PIPE\\svcctl"
|
||||
#define PIPE_EVENTLOG "\\PIPE\\eventlog"
|
||||
#define PIPE_UNIXINFO "\\PIPE\\unixinfo"
|
||||
|
||||
#define PIPE_NETLOGON_PLAIN "\\NETLOGON"
|
||||
|
||||
@ -206,10 +204,8 @@ typedef uint32 codepoint_t;
|
||||
#define PI_INITSHUTDOWN 10
|
||||
#define PI_SVCCTL 11
|
||||
#define PI_EVENTLOG 12
|
||||
#define PI_UNIXINFO 13
|
||||
#define PI_NTSVCS 14
|
||||
#define PI_EPMAPPER 15
|
||||
#define PI_MAX_PIPES 16
|
||||
#define PI_NTSVCS 13
|
||||
#define PI_MAX_PIPES 14
|
||||
|
||||
/* 64 bit time (100usec) since ????? - cifs6.txt, section 3.5, page 30 */
|
||||
typedef uint64_t NTTIME;
|
||||
@ -304,11 +300,10 @@ struct id_map {
|
||||
#include "librpc/ndr/misc.h"
|
||||
#include "librpc/ndr/security.h"
|
||||
#include "librpc/ndr/libndr.h"
|
||||
#include "librpc/gen_ndr/unixinfo.h"
|
||||
#include "librpc/gen_ndr/lsa.h"
|
||||
#include "librpc/gen_ndr/dfs.h"
|
||||
#include "librpc/gen_ndr/initshutdown.h"
|
||||
#include "librpc/gen_ndr/winreg.h"
|
||||
#include "librpc/gen_ndr/initshutdown.h"
|
||||
#include "librpc/gen_ndr/eventlog.h"
|
||||
#include "librpc/gen_ndr/srvsvc.h"
|
||||
#include "librpc/gen_ndr/wkssvc.h"
|
||||
@ -507,6 +502,7 @@ typedef struct files_struct {
|
||||
BOOL modified;
|
||||
BOOL is_directory;
|
||||
BOOL is_stat;
|
||||
BOOL aio_write_behind;
|
||||
BOOL lockdb_clean;
|
||||
BOOL initial_delete_on_close; /* Only set at NTCreateX if file was created. */
|
||||
BOOL posix_open;
|
||||
@ -657,6 +653,7 @@ typedef struct connection_struct {
|
||||
name_compare_entry *hide_list; /* Per-share list of files to return as hidden. */
|
||||
name_compare_entry *veto_list; /* Per-share list of files to veto (never show). */
|
||||
name_compare_entry *veto_oplock_list; /* Per-share list of files to refuse oplocks on. */
|
||||
name_compare_entry *aio_write_behind_list; /* Per-share list of files to use aio write behind on. */
|
||||
struct dfree_cached_info *dfree_info;
|
||||
struct trans_state *pending_trans;
|
||||
struct notify_context *notify_ctx;
|
||||
@ -1918,6 +1915,4 @@ enum usershare_err {
|
||||
/* Different reasons for closing a file. */
|
||||
enum file_close_type {NORMAL_CLOSE=0,SHUTDOWN_CLOSE,ERROR_CLOSE};
|
||||
|
||||
#include "librpc/gen_ndr/epmapper.h"
|
||||
|
||||
#endif /* _SMB_H */
|
||||
|
@ -1,42 +0,0 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
Launchd integration wrapper API
|
||||
|
||||
Copyright (C) James Peach 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
struct smb_launch_info
|
||||
{
|
||||
int idle_timeout_secs;
|
||||
int num_sockets;
|
||||
int *socket_list;
|
||||
};
|
||||
|
||||
/* Retrieve launchd configuration. Returns True if we are running under
|
||||
* launchd, False otherwise. NOTE this does not guarantee to provide a list of
|
||||
* sockets since this is a user configuration option.
|
||||
*/
|
||||
BOOL smb_launchd_checkin(struct smb_launch_info *linfo);
|
||||
|
||||
/* Retrieve launchd configuration. The variadic arguments are a list of
|
||||
* constant null-terminated strings. The strings are the names of the socket
|
||||
* dictionaries to retrieve sockets from. The list of names is terminated by a
|
||||
* NULL.
|
||||
*/
|
||||
BOOL smb_launchd_checkin_names(struct smb_launch_info *linfo, ...);
|
||||
|
||||
/* Free any data or state associated with a successful launchd checkin. */
|
||||
void smb_launchd_checkout(struct smb_launch_info *linfo);
|
@ -158,10 +158,11 @@
|
||||
#define SMB_LARGE_LKLEN_OFFSET_HIGH(indx) (12 + (20 * (indx)))
|
||||
#define SMB_LARGE_LKLEN_OFFSET_LOW(indx) (16 + (20 * (indx)))
|
||||
|
||||
#define ERROR_DOS(class,code) error_packet(inbuf,outbuf,class,code,NT_STATUS_OK,__LINE__,__FILE__)
|
||||
#define ERROR_NT(status) error_packet(inbuf,outbuf,0,0,status,__LINE__,__FILE__)
|
||||
#define ERROR_FORCE_NT(status) error_packet(inbuf,outbuf,-1,-1,status,__LINE__,__FILE__)
|
||||
#define ERROR_BOTH(status,class,code) error_packet(inbuf,outbuf,class,code,status,__LINE__,__FILE__)
|
||||
#define ERROR_DOS(class,code) error_packet(outbuf,class,code,NT_STATUS_OK,__LINE__,__FILE__)
|
||||
#define ERROR_NT(status) error_packet(outbuf,0,0,status,__LINE__,__FILE__)
|
||||
#define ERROR_OPEN(status) error_open(outbuf,status,__LINE__,__FILE__)
|
||||
#define ERROR_FORCE_NT(status) error_packet(outbuf,-1,-1,status,__LINE__,__FILE__)
|
||||
#define ERROR_BOTH(status,class,code) error_packet(outbuf,class,code,status,__LINE__,__FILE__)
|
||||
|
||||
#define reply_nterror(req,status) reply_nt_error(req,status,__LINE__,__FILE__)
|
||||
#define reply_force_nterror(req,status) reply_force_nt_error(req,status,__LINE__,__FILE__)
|
||||
@ -170,7 +171,7 @@
|
||||
#define reply_unixerror(req,defclass,deferror) reply_unix_error(req,defclass,deferror,NT_STATUS_OK,__LINE__,__FILE__)
|
||||
|
||||
/* this is how errors are generated */
|
||||
#define UNIXERROR(defclass,deferror) unix_error_packet(inbuf,outbuf,defclass,deferror,NT_STATUS_OK,__LINE__,__FILE__)
|
||||
#define UNIXERROR(defclass,deferror) unix_error_packet(outbuf,defclass,deferror,NT_STATUS_OK,__LINE__,__FILE__)
|
||||
|
||||
/* these are the datagram types */
|
||||
#define DGRAM_DIRECT_UNIQUE 0x10
|
||||
@ -378,4 +379,12 @@ do { \
|
||||
#define ADD_TO_LARGE_ARRAY(mem_ctx, type, elem, array, num, size) \
|
||||
add_to_large_array((mem_ctx), sizeof(type), &(elem), (void *)(array), (num), (size));
|
||||
|
||||
#ifndef ISDOT
|
||||
#define ISDOT(p) (*(p) == '.' && *((p) + 1) == '\0')
|
||||
#endif /* ISDOT */
|
||||
|
||||
#ifndef ISDOTDOT
|
||||
#define ISDOTDOT(p) (*(p) == '.' && *((p) + 1) == '.' && *((p) + 2) == '\0')
|
||||
#endif /* ISDOTDOT */
|
||||
|
||||
#endif /* _SMB_MACROS_H */
|
||||
|
@ -530,8 +530,7 @@ findfirst/findnext is SMB_FIND_FILE_UNIX_INFO2.
|
||||
#define CIFS_UNIX_POSIX_PATH_OPERATIONS_CAP 0x20 /* We can cope with POSIX open/mkdir/unlink etc. */
|
||||
#define CIFS_UNIX_LARGE_READ_CAP 0x40 /* We can cope with 24 bit reads in readX. */
|
||||
#define CIFS_UNIX_LARGE_WRITE_CAP 0x80 /* We can cope with 24 bit writes in writeX. */
|
||||
#define CIFS_UNIX_TRANSPORT_ENCRYPTION_CAP 0x100 /* We can do SPNEGO negotiations for encryption. */
|
||||
#define CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP 0x200 /* We *must* SPNEGO negotiations for encryption. */
|
||||
|
||||
|
||||
#define SMB_QUERY_POSIX_FS_INFO 0x201
|
||||
|
||||
@ -654,27 +653,6 @@ enum smb_whoami_flags {
|
||||
DOM_SID[] - list of SIDs (may be empty)
|
||||
*/
|
||||
|
||||
/*
|
||||
* The following trans2 is done between client and server
|
||||
* as a FSINFO call to set up the encryption state for transport
|
||||
* encryption.
|
||||
*
|
||||
* The request looks like :
|
||||
*
|
||||
* [data block] -> SPNEGO framed GSSAPI request.
|
||||
*
|
||||
* The reply looks like :
|
||||
*
|
||||
* [data block] -> SPNEGO framed GSSAPI reply - if error
|
||||
* is NT_STATUS_OK then we're done, if it's
|
||||
* NT_STATUS_MORE_PROCESSING_REQUIRED then the
|
||||
* client needs to keep going. If it's an
|
||||
* error it can be any NT_STATUS error.
|
||||
*
|
||||
*/
|
||||
|
||||
#define SMB_REQUEST_TRANSPORT_ENCRYPTION 0x203
|
||||
|
||||
/* The query/set info levels for POSIX ACLs. */
|
||||
#define SMB_QUERY_POSIX_ACL 0x204
|
||||
#define SMB_SET_POSIX_ACL 0x204
|
||||
|
@ -72,8 +72,7 @@ static struct db_record *db_tdb_fetch_locked(struct db_context *db,
|
||||
result->delete_rec = db_tdb_delete;
|
||||
|
||||
if (DEBUGLEVEL > 10) {
|
||||
char *keystr = hex_encode(NULL, (unsigned char *)key.dptr,
|
||||
key.dsize);
|
||||
char *keystr = hex_encode(NULL, key.dptr, key.dsize);
|
||||
DEBUG(10, (DEBUGLEVEL > 10
|
||||
? "Locking key %s\n" : "Locking key %20s\n",
|
||||
keystr));
|
||||
|
@ -47,23 +47,3 @@ NTSTATUS can_delete_directory(struct connection_struct *conn,
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
NTSTATUS srv_decrypt_buffer(char *buf)
|
||||
{
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
NTSTATUS srv_encrypt_buffer(char *buffer, char **buf_out)
|
||||
{
|
||||
*buf_out = buffer;
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
void srv_free_enc_buffer(char *buf)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
BOOL srv_encryption_on(void)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
@ -1,241 +0,0 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
Launchd integration wrapper API
|
||||
|
||||
Copyright (C) 2007 James Peach
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
#include "smb_launchd.h"
|
||||
|
||||
/* launchd source code and documentation is available here:
|
||||
* http://launchd.macosforge.org/
|
||||
*/
|
||||
|
||||
#if defined(WITH_LAUNCHD_SUPPORT)
|
||||
|
||||
#include <launch.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
typedef void (*launchd_iterator)(launch_data_t, const char*, void*);
|
||||
|
||||
#define LAUNCHD_TRACE_LEVEL 10
|
||||
|
||||
void smb_launchd_checkout(struct smb_launch_info *linfo)
|
||||
{
|
||||
talloc_free(linfo->socket_list);
|
||||
}
|
||||
|
||||
static void pull_launch_sockets(launch_data_t key,
|
||||
const char *name,
|
||||
struct smb_launch_info *linfo)
|
||||
{
|
||||
launch_data_type_t type;
|
||||
|
||||
type = launch_data_get_type(key);
|
||||
DEBUG(LAUNCHD_TRACE_LEVEL,
|
||||
("Searching item name='%s' type=%d for sockets\n",
|
||||
name ? name : "", (int)type));
|
||||
|
||||
switch (type) {
|
||||
case LAUNCH_DATA_FD:
|
||||
if (!linfo->socket_list) {
|
||||
/* We are counting the number of sockets. */
|
||||
linfo->num_sockets++;
|
||||
} else {
|
||||
/* We are collecting the socket fds. */
|
||||
int fd = launch_data_get_fd(key);
|
||||
|
||||
linfo->socket_list[linfo->num_sockets] = fd;
|
||||
linfo->num_sockets++;
|
||||
DEBUG(LAUNCHD_TRACE_LEVEL,
|
||||
("Added fd=%d to launchd set\n", fd));
|
||||
}
|
||||
return;
|
||||
case LAUNCH_DATA_ARRAY:
|
||||
{
|
||||
int i;
|
||||
launch_data_t item;
|
||||
|
||||
for (i = 0; i < launch_data_array_get_count(key); ++i) {
|
||||
item = launch_data_array_get_index(key, i);
|
||||
pull_launch_sockets(item, name, linfo);
|
||||
}
|
||||
return;
|
||||
}
|
||||
case LAUNCH_DATA_DICTIONARY:
|
||||
launch_data_dict_iterate(key,
|
||||
(launchd_iterator)pull_launch_sockets, linfo);
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL smb_launchd_checkin_names(struct smb_launch_info *linfo, ...)
|
||||
{
|
||||
launch_data_t msg;
|
||||
launch_data_t resp;
|
||||
launch_data_t item;
|
||||
BOOL is_launchd = False;
|
||||
|
||||
ZERO_STRUCTP(linfo);
|
||||
|
||||
msg = launch_data_new_string(LAUNCH_KEY_CHECKIN);
|
||||
resp = launch_msg(msg);
|
||||
if (resp == NULL) {
|
||||
/* IPC to launchd failed. */
|
||||
launch_data_free(msg);
|
||||
return is_launchd;
|
||||
}
|
||||
|
||||
if (launch_data_get_type(resp) == LAUNCH_DATA_ERRNO) {
|
||||
errno = launch_data_get_errno(resp);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* At this point, we know we are running under launchd. */
|
||||
linfo->idle_timeout_secs = 600;
|
||||
is_launchd = True;
|
||||
|
||||
if ((item = launch_data_dict_lookup(resp, LAUNCH_JOBKEY_TIMEOUT))) {
|
||||
linfo->idle_timeout_secs = launch_data_get_integer(item);
|
||||
}
|
||||
|
||||
if ((item = launch_data_dict_lookup(resp, LAUNCH_JOBKEY_SOCKETS))) {
|
||||
int count = 0;
|
||||
const char * sockname = NULL;
|
||||
launch_data_t sockdata;
|
||||
va_list args;
|
||||
|
||||
/* Figure out the maximum number of sockets. */
|
||||
va_start(args, linfo);
|
||||
while ((sockname = va_arg(args, const char *))) {
|
||||
++count;
|
||||
}
|
||||
va_end(args);
|
||||
|
||||
DEBUG(LAUNCHD_TRACE_LEVEL, ("Found %d launchd sockets\n",
|
||||
linfo->num_sockets));
|
||||
|
||||
if (launch_data_dict_get_count(item) < count) {
|
||||
DEBUG(0, ("%d launchd sockets requested, "
|
||||
"but only %d are available\n",
|
||||
count, launch_data_dict_get_count(item)));
|
||||
}
|
||||
|
||||
linfo->socket_list = TALLOC_ARRAY(NULL, int, count);
|
||||
if (linfo->socket_list == NULL) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
linfo->num_sockets = 0;
|
||||
va_start(args, linfo);
|
||||
while ((sockname = va_arg(args, const char *))) {
|
||||
sockdata = launch_data_dict_lookup(item, sockname);
|
||||
|
||||
pull_launch_sockets(sockdata, sockname, linfo);
|
||||
DEBUG(LAUNCHD_TRACE_LEVEL,
|
||||
("Added launchd socket \"%s\"\n", sockname));
|
||||
}
|
||||
|
||||
SMB_ASSERT(count >= linfo->num_sockets);
|
||||
}
|
||||
|
||||
done:
|
||||
launch_data_free(msg);
|
||||
launch_data_free(resp);
|
||||
return is_launchd;
|
||||
}
|
||||
|
||||
BOOL smb_launchd_checkin(struct smb_launch_info *linfo)
|
||||
{
|
||||
launch_data_t msg;
|
||||
launch_data_t resp;
|
||||
launch_data_t item;
|
||||
BOOL is_launchd = False;
|
||||
|
||||
ZERO_STRUCTP(linfo);
|
||||
|
||||
msg = launch_data_new_string(LAUNCH_KEY_CHECKIN);
|
||||
resp = launch_msg(msg);
|
||||
if (resp == NULL) {
|
||||
/* IPC to launchd failed. */
|
||||
launch_data_free(msg);
|
||||
return is_launchd;
|
||||
}
|
||||
|
||||
if (launch_data_get_type(resp) == LAUNCH_DATA_ERRNO) {
|
||||
errno = launch_data_get_errno(resp);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* At this point, we know we are running under launchd. */
|
||||
linfo->idle_timeout_secs = 600;
|
||||
is_launchd = True;
|
||||
|
||||
if ((item = launch_data_dict_lookup(resp, LAUNCH_JOBKEY_TIMEOUT))) {
|
||||
linfo->idle_timeout_secs = launch_data_get_integer(item);
|
||||
}
|
||||
|
||||
if ((item = launch_data_dict_lookup(resp, LAUNCH_JOBKEY_SOCKETS))) {
|
||||
int count;
|
||||
|
||||
pull_launch_sockets(item, NULL, linfo);
|
||||
DEBUG(LAUNCHD_TRACE_LEVEL, ("Found %d launchd sockets\n",
|
||||
linfo->num_sockets));
|
||||
|
||||
count = linfo->num_sockets;
|
||||
linfo->socket_list = TALLOC_ARRAY(NULL, int, count);
|
||||
if (linfo->socket_list == NULL) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
linfo->num_sockets = 0;
|
||||
pull_launch_sockets(item, NULL, linfo);
|
||||
|
||||
DEBUG(LAUNCHD_TRACE_LEVEL, ("Added %d launchd sockets\n",
|
||||
linfo->num_sockets));
|
||||
|
||||
SMB_ASSERT(count == linfo->num_sockets);
|
||||
}
|
||||
|
||||
done:
|
||||
launch_data_free(msg);
|
||||
launch_data_free(resp);
|
||||
return is_launchd;
|
||||
}
|
||||
|
||||
#else /* defined(WITH_LAUNCHD_SUPPORT) */
|
||||
|
||||
BOOL smb_launchd_checkin(struct smb_launch_info * UNUSED(linfo))
|
||||
{
|
||||
ZERO_STRUCTP(linfo);
|
||||
return False;
|
||||
}
|
||||
|
||||
BOOL smb_launchd_checkin_names(struct smb_launch_info * UNUSED(linfo), ...)
|
||||
{
|
||||
ZERO_STRUCTP(linfo);
|
||||
return False;
|
||||
}
|
||||
|
||||
void smb_launchd_checkout(struct smb_launch_info * UNUSED(linfo))
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* defined(WITH_LAUNCHD_SUPPORT) */
|
||||
|
0
source3/lib/replace/system/getaddrinfo.h
Normal file
0
source3/lib/replace/system/getaddrinfo.h
Normal file
@ -767,3 +767,21 @@ void standard_sub_advanced(const char *servicename, const char *user,
|
||||
SAFE_FREE( s );
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Do some standard substitutions in a string.
|
||||
* ****************************************************************************/
|
||||
|
||||
void standard_sub_conn(connection_struct *conn, char *str, size_t len)
|
||||
{
|
||||
char *s;
|
||||
|
||||
s = alloc_sub_advanced(lp_servicename(SNUM(conn)), conn->user, conn->connectpath,
|
||||
conn->gid, smb_user_name, "", str);
|
||||
|
||||
if ( s ) {
|
||||
strncpy( str, s, len );
|
||||
SAFE_FREE( s );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,10 @@
|
||||
typedef uint32_t tdb_len_t;
|
||||
typedef uint32_t tdb_off_t;
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(t,f) ((unsigned int)&((t *)0)->f)
|
||||
#endif
|
||||
|
||||
#define TDB_MAGIC_FOOD "TDB file\n"
|
||||
#define TDB_VERSION (0x26011967 + 6)
|
||||
#define TDB_MAGIC (0x26011999U)
|
||||
|
@ -515,50 +515,31 @@ void show_msg(char *buf)
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Set the length and marker of an encrypted smb packet.
|
||||
Set the length and marker of an smb packet.
|
||||
********************************************************************/
|
||||
|
||||
void smb_set_enclen(char *buf,int len,uint16 enc_ctx_num)
|
||||
void smb_setlen(char *buf,int len)
|
||||
{
|
||||
_smb_setlen(buf,len);
|
||||
|
||||
SCVAL(buf,4,0xFF);
|
||||
SCVAL(buf,5,'E');
|
||||
SSVAL(buf,6,enc_ctx_num);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Set the length and marker of an smb packet.
|
||||
********************************************************************/
|
||||
|
||||
void smb_setlen(const char *frombuf, char *buf, int len)
|
||||
{
|
||||
_smb_setlen(buf,len);
|
||||
|
||||
if (frombuf) {
|
||||
if (buf != frombuf) {
|
||||
memcpy(buf+4, frombuf+4, 4);
|
||||
}
|
||||
} else {
|
||||
SCVAL(buf,4,0xFF);
|
||||
SCVAL(buf,5,'S');
|
||||
SCVAL(buf,6,'M');
|
||||
SCVAL(buf,7,'B');
|
||||
}
|
||||
SCVAL(buf,5,'S');
|
||||
SCVAL(buf,6,'M');
|
||||
SCVAL(buf,7,'B');
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Setup the word count and byte count for a smb message.
|
||||
********************************************************************/
|
||||
|
||||
int set_message(const char *frombuf, char *buf,int num_words,int num_bytes,BOOL zero)
|
||||
int set_message(char *buf,int num_words,int num_bytes,BOOL zero)
|
||||
{
|
||||
if (zero && (num_words || num_bytes)) {
|
||||
memset(buf + smb_size,'\0',num_words*2 + num_bytes);
|
||||
}
|
||||
SCVAL(buf,smb_wct,num_words);
|
||||
SSVAL(buf,smb_vwv + num_words*SIZEOFWORD,num_bytes);
|
||||
smb_setlen(frombuf, buf,smb_size + num_words*2 + num_bytes - 4);
|
||||
smb_setlen(buf,smb_size + num_words*2 + num_bytes - 4);
|
||||
return (smb_size + num_words*2 + num_bytes);
|
||||
}
|
||||
|
||||
@ -566,11 +547,11 @@ int set_message(const char *frombuf, char *buf,int num_words,int num_bytes,BOOL
|
||||
Setup only the byte count for a smb message.
|
||||
********************************************************************/
|
||||
|
||||
int set_message_bcc(const char *frombuf, char *buf,int num_bytes)
|
||||
int set_message_bcc(char *buf,int num_bytes)
|
||||
{
|
||||
int num_words = CVAL(buf,smb_wct);
|
||||
SSVAL(buf,smb_vwv + num_words*SIZEOFWORD,num_bytes);
|
||||
smb_setlen(frombuf, buf,smb_size + num_words*2 + num_bytes - 4);
|
||||
smb_setlen(buf,smb_size + num_words*2 + num_bytes - 4);
|
||||
return (smb_size + num_words*2 + num_bytes);
|
||||
}
|
||||
|
||||
@ -579,11 +560,9 @@ int set_message_bcc(const char *frombuf, char *buf,int num_bytes)
|
||||
message as a marker.
|
||||
********************************************************************/
|
||||
|
||||
int set_message_end(const char *frombuf, void *outbuf,void *end_ptr)
|
||||
int set_message_end(void *outbuf,void *end_ptr)
|
||||
{
|
||||
return set_message_bcc(frombuf,
|
||||
(char *)outbuf,
|
||||
PTR_DIFF(end_ptr,smb_buf((char *)outbuf)));
|
||||
return set_message_bcc((char *)outbuf,PTR_DIFF(end_ptr,smb_buf((char *)outbuf)));
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
@ -603,7 +582,7 @@ ssize_t message_push_blob(uint8 **outbuf, DATA_BLOB blob)
|
||||
*outbuf = tmp;
|
||||
|
||||
memcpy(tmp + smb_len(tmp) + 4, blob.data, blob.length);
|
||||
set_message_bcc(NULL, (char *)tmp, smb_buflen(tmp) + blob.length);
|
||||
set_message_bcc((char *)tmp, smb_buflen(tmp) + blob.length);
|
||||
return blob.length;
|
||||
}
|
||||
|
||||
@ -2296,8 +2275,9 @@ void print_asc(int level, const unsigned char *buf,int len)
|
||||
DEBUG(level,("%c", isprint(buf[i])?buf[i]:'.'));
|
||||
}
|
||||
|
||||
void dump_data(int level, const unsigned char *buf,int len)
|
||||
void dump_data(int level, const unsigned char *buf1,int len)
|
||||
{
|
||||
const unsigned char *buf = (const unsigned char *)buf1;
|
||||
int i=0;
|
||||
if (len<=0) return;
|
||||
|
||||
|
@ -815,19 +815,6 @@ BOOL receive_smb(int fd, char *buffer, unsigned int timeout)
|
||||
return False;
|
||||
}
|
||||
|
||||
if (srv_encryption_on()) {
|
||||
NTSTATUS status = srv_decrypt_buffer(buffer);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DEBUG(0, ("receive_smb: SMB decryption failed "
|
||||
"on incoming packet! Error %s\n",
|
||||
nt_errstr(status) ));
|
||||
if (smb_read_error == 0) {
|
||||
smb_read_error = READ_BAD_DECRYPT;
|
||||
}
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check the incoming SMB signature. */
|
||||
if (!srv_check_sign_mac(buffer, True)) {
|
||||
DEBUG(0, ("receive_smb: SMB Signature verification "
|
||||
@ -852,19 +839,6 @@ ssize_t receive_smb_talloc(TALLOC_CTX *mem_ctx, int fd, char **buffer,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (srv_encryption_on()) {
|
||||
NTSTATUS status = srv_decrypt_buffer(*buffer);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DEBUG(0, ("receive_smb: SMB decryption failed on "
|
||||
"incoming packet! Error %s\n",
|
||||
nt_errstr(status) ));
|
||||
if (smb_read_error == 0) {
|
||||
smb_read_error = READ_BAD_DECRYPT;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check the incoming SMB signature. */
|
||||
if (!srv_check_sign_mac(*buffer, True)) {
|
||||
DEBUG(0, ("receive_smb: SMB Signature verification failed on "
|
||||
@ -887,35 +861,22 @@ BOOL send_smb(int fd, char *buffer)
|
||||
size_t len;
|
||||
size_t nwritten=0;
|
||||
ssize_t ret;
|
||||
char *buf_out = buffer;
|
||||
|
||||
/* Sign the outgoing packet if required. */
|
||||
srv_calculate_sign_mac(buf_out);
|
||||
srv_calculate_sign_mac(buffer);
|
||||
|
||||
if (srv_encryption_on()) {
|
||||
NTSTATUS status = srv_encrypt_buffer(buffer, &buf_out);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DEBUG(0, ("send_smb: SMB encryption failed "
|
||||
"on outgoing packet! Error %s\n",
|
||||
nt_errstr(status) ));
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
len = smb_len(buf_out) + 4;
|
||||
len = smb_len(buffer) + 4;
|
||||
|
||||
while (nwritten < len) {
|
||||
ret = write_data(fd,buf_out+nwritten,len - nwritten);
|
||||
ret = write_data(fd,buffer+nwritten,len - nwritten);
|
||||
if (ret <= 0) {
|
||||
DEBUG(0,("Error writing %d bytes to client. %d. (%s)\n",
|
||||
(int)len,(int)ret, strerror(errno) ));
|
||||
srv_free_enc_buffer(buf_out);
|
||||
return False;
|
||||
}
|
||||
nwritten += ret;
|
||||
}
|
||||
|
||||
srv_free_enc_buffer(buf_out);
|
||||
return True;
|
||||
}
|
||||
|
||||
|
@ -447,7 +447,6 @@ BOOL strisnormal(const char *s, int case_default)
|
||||
String replace.
|
||||
NOTE: oldc and newc must be 7 bit characters
|
||||
**/
|
||||
|
||||
void string_replace( char *s, char oldc, char newc )
|
||||
{
|
||||
char *p;
|
||||
|
@ -83,10 +83,6 @@ NTSTATUS ads_ntstatus(ADS_STATUS status)
|
||||
#ifdef HAVE_KRB5
|
||||
case ENUM_ADS_ERROR_KRB5:
|
||||
return krb5_to_nt_status(status.err.rc);
|
||||
#endif
|
||||
#ifdef HAVE_GSSAPI
|
||||
case ENUM_ADS_ERROR_GSS:
|
||||
return map_nt_error_from_gss(status.err.rc, status.minor_status);
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
@ -146,12 +142,3 @@ const char *ads_errstr(ADS_STATUS status)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_GSSAPI
|
||||
NTSTATUS gss_err_to_ntstatus(uint32 maj, uint32 min)
|
||||
{
|
||||
ADS_STATUS adss = ADS_ERROR_GSS(maj, min);
|
||||
DEBUG(10,("gss_err_to_ntstatus: Error %s\n",
|
||||
ads_errstr(adss) ));
|
||||
return ads_ntstatus(adss);
|
||||
}
|
||||
#endif
|
||||
|
@ -60,8 +60,8 @@ static ADS_STATUS ads_do_search_retry_internal(ADS_STRUCT *ads, const char *bind
|
||||
status = ads_do_search_all_args(ads, bp, scope, expr, attrs, args, res);
|
||||
}
|
||||
if (ADS_ERR_OK(status)) {
|
||||
DEBUG(5,("Search for %s in <%s> gave %d replies\n",
|
||||
expr, bp, ads_count_replies(ads, *res)));
|
||||
DEBUG(5,("Search for %s in <%s> gave %d replies\n",
|
||||
expr, bp, ads_count_replies(ads, *res)));
|
||||
SAFE_FREE(bp);
|
||||
return status;
|
||||
}
|
||||
@ -159,6 +159,21 @@ static ADS_STATUS ads_do_search_retry_internal(ADS_STRUCT *ads, const char *bind
|
||||
"(objectclass=*)", attrs, &args, res);
|
||||
}
|
||||
|
||||
ADS_STATUS ads_search_retry_dn_sd_flags(ADS_STRUCT *ads, LDAPMessage **res,
|
||||
uint32 sd_flags,
|
||||
const char *dn,
|
||||
const char **attrs)
|
||||
{
|
||||
ads_control args;
|
||||
|
||||
args.control = ADS_SD_FLAGS_OID;
|
||||
args.val = sd_flags;
|
||||
args.critical = True;
|
||||
|
||||
return ads_do_search_retry_args(ads, dn, LDAP_SCOPE_BASE,
|
||||
"(objectclass=*)", attrs, &args, res);
|
||||
}
|
||||
|
||||
ADS_STATUS ads_search_retry_extended_dn_ranged(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx,
|
||||
const char *dn,
|
||||
const char **attrs,
|
||||
@ -181,21 +196,6 @@ static ADS_STATUS ads_do_search_retry_internal(ADS_STRUCT *ads, const char *bind
|
||||
"(objectclass=*)", &args, attrs[0],
|
||||
strings, num_strings);
|
||||
|
||||
}
|
||||
|
||||
ADS_STATUS ads_search_retry_dn_sd_flags(ADS_STRUCT *ads, LDAPMessage **res,
|
||||
uint32 sd_flags,
|
||||
const char *dn,
|
||||
const char **attrs)
|
||||
{
|
||||
ads_control args;
|
||||
|
||||
args.control = ADS_SD_FLAGS_OID;
|
||||
args.val = sd_flags;
|
||||
args.critical = True;
|
||||
|
||||
return ads_do_search_retry_args(ads, dn, LDAP_SCOPE_BASE,
|
||||
"(objectclass=*)", attrs, &args, res);
|
||||
}
|
||||
|
||||
ADS_STATUS ads_search_retry_sid(ADS_STRUCT *ads, LDAPMessage **res,
|
||||
|
@ -1,173 +0,0 @@
|
||||
# Doxyfile 0.1
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# General configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
PROJECT_NAME = libmsrpc
|
||||
PROJECT_NUMBER =
|
||||
|
||||
# NOTE: By default, Doxygen writes into the dox/ subdirectory of the
|
||||
# invocation directory. If you want to put it somewhere else, for
|
||||
# example, to write straight into a webserver directory, then override
|
||||
# this variable in a configuration concatenated to this one: Doxygen
|
||||
# doesn't mind variables being redefined.
|
||||
|
||||
OUTPUT_DIRECTORY = dox
|
||||
|
||||
OUTPUT_LANGUAGE = English
|
||||
EXTRACT_ALL = YES
|
||||
EXTRACT_PRIVATE = YES
|
||||
EXTRACT_STATIC = YES
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
FULL_PATH_NAMES = YES
|
||||
STRIP_FROM_PATH = $(PWD)/
|
||||
INTERNAL_DOCS = YES
|
||||
CLASS_DIAGRAMS = YES
|
||||
SOURCE_BROWSER = YES
|
||||
INLINE_SOURCES = YES
|
||||
STRIP_CODE_COMMENTS = NO
|
||||
CASE_SENSE_NAMES = YES
|
||||
SHORT_NAMES = NO
|
||||
HIDE_SCOPE_NAMES = YES
|
||||
VERBATIM_HEADERS = YES
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
JAVADOC_AUTOBRIEF = YES
|
||||
INHERIT_DOCS = YES
|
||||
INLINE_INFO = YES
|
||||
SORT_MEMBER_DOCS = NO
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
TAB_SIZE = 8
|
||||
GENERATE_TODOLIST = YES
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
ALIASES =
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
OPTIMIZE_OUTPUT_FOR_C = YES
|
||||
SHOW_USED_FILES = YES
|
||||
REFERENCED_BY_RELATION = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
QUIET = YES
|
||||
WARNINGS = NO
|
||||
WARN_IF_UNDOCUMENTED = NO
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = ../include/
|
||||
FILE_PATTERNS = libmsrpc.h
|
||||
RECURSIVE = YES
|
||||
EXCLUDE =
|
||||
EXCLUDE_PATTERNS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS =
|
||||
IMAGE_PATH =
|
||||
INPUT_FILTER =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
ALPHABETICAL_INDEX = YES
|
||||
COLS_IN_ALPHA_INDEX = 1
|
||||
IGNORE_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = .
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER =
|
||||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
GENERATE_HTMLHELP = NO
|
||||
GENERATE_CHI = NO
|
||||
BINARY_TOC = NO
|
||||
TOC_EXPAND = NO
|
||||
DISABLE_INDEX = NO
|
||||
ENUM_VALUES_PER_LINE = 3
|
||||
GENERATE_TREEVIEW = NO
|
||||
TREEVIEW_WIDTH = 250
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_LATEX = NO
|
||||
LATEX_OUTPUT = latex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4wide
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
PDF_HYPERLINKS = YES
|
||||
USE_PDFLATEX = YES
|
||||
LATEX_BATCHMODE = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_RTF = NO
|
||||
RTF_OUTPUT = rtf
|
||||
COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_MAN = NO
|
||||
MAN_OUTPUT = man
|
||||
MAN_EXTENSION = .3
|
||||
MAN_LINKS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the XML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_XML = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
ENABLE_PREPROCESSING = NO
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED =
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration::additions related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE =
|
||||
ALLEXTERNALS = NO
|
||||
PERL_PATH = /usr/bin/perl
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
HAVE_DOT = NO
|
||||
CLASS_GRAPH = YES
|
||||
COLLABORATION_GRAPH = YES
|
||||
TEMPLATE_RELATIONS = YES
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DOT_PATH =
|
||||
DOTFILE_DIRS =
|
||||
MAX_DOT_GRAPH_WIDTH = 1024
|
||||
MAX_DOT_GRAPH_HEIGHT = 1024
|
||||
GENERATE_LEGEND = YES
|
||||
DOT_CLEANUP = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration::additions related to the search engine
|
||||
#---------------------------------------------------------------------------
|
||||
SEARCHENGINE = NO
|
||||
CGI_NAME = search.cgi
|
||||
CGI_URL =
|
||||
DOC_URL =
|
||||
DOC_ABSPATH =
|
||||
BIN_ABSPATH = /usr/local/bin/
|
||||
EXT_DOC_PATHS =
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,631 +0,0 @@
|
||||
|
||||
/*
|
||||
* Unix SMB/CIFS implementation.
|
||||
* MS-RPC client library implementation (SVCCTL pipe)
|
||||
* Copyright (C) Chris Nicholls 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
#include "libsmb_internal.h"
|
||||
|
||||
#define WAIT_SLEEP_TIME 300000
|
||||
|
||||
int cac_WaitForService( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
|
||||
POLICY_HND * svc_hnd, uint32 state, uint32 timeout,
|
||||
SERVICE_STATUS * status );
|
||||
|
||||
int cac_SvcOpenScm( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
|
||||
struct SvcOpenScm *op )
|
||||
{
|
||||
SMBCSRV *srv = NULL;
|
||||
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||
WERROR err;
|
||||
|
||||
POLICY_HND *scm_out = NULL;
|
||||
|
||||
if ( !hnd )
|
||||
return CAC_FAILURE;
|
||||
|
||||
if ( !hnd->_internal.ctx ) {
|
||||
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
if ( !op || op->in.access == 0 || !mem_ctx ) {
|
||||
hnd->status = NT_STATUS_INVALID_PARAMETER;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
srv = cac_GetServer( hnd );
|
||||
if ( !srv ) {
|
||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
/*initialize for samr pipe if we have to */
|
||||
if ( !hnd->_internal.pipes[PI_SVCCTL] ) {
|
||||
if ( !
|
||||
( pipe_hnd =
|
||||
cli_rpc_pipe_open_noauth( srv->cli, PI_SVCCTL,
|
||||
&( hnd->status ) ) ) ) {
|
||||
hnd->status = NT_STATUS_UNSUCCESSFUL;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
hnd->_internal.pipes[PI_SVCCTL] = True;
|
||||
}
|
||||
|
||||
scm_out = talloc( mem_ctx, POLICY_HND );
|
||||
if ( !scm_out ) {
|
||||
hnd->status = NT_STATUS_NO_MEMORY;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
err = rpccli_svcctl_open_scm( pipe_hnd, mem_ctx, scm_out,
|
||||
op->in.access );
|
||||
hnd->status = werror_to_ntstatus( err );
|
||||
|
||||
if ( !NT_STATUS_IS_OK( hnd->status ) )
|
||||
return CAC_FAILURE;
|
||||
|
||||
op->out.scm_hnd = scm_out;
|
||||
|
||||
return CAC_SUCCESS;
|
||||
}
|
||||
|
||||
int cac_SvcClose( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
|
||||
POLICY_HND * scm_hnd )
|
||||
{
|
||||
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||
|
||||
if ( !hnd )
|
||||
return CAC_FAILURE;
|
||||
|
||||
if ( !hnd->_internal.ctx ) {
|
||||
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
if ( !scm_hnd || !mem_ctx ) {
|
||||
hnd->status = NT_STATUS_INVALID_PARAMETER;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
|
||||
if ( !pipe_hnd ) {
|
||||
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
hnd->status = rpccli_svcctl_CloseServiceHandle( pipe_hnd, mem_ctx, scm_hnd );
|
||||
|
||||
if ( !NT_STATUS_IS_OK( hnd->status ) )
|
||||
return CAC_FAILURE;
|
||||
|
||||
return CAC_SUCCESS;
|
||||
}
|
||||
|
||||
int cac_SvcEnumServices( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
|
||||
struct SvcEnumServices *op )
|
||||
{
|
||||
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||
WERROR err;
|
||||
|
||||
uint32 type_buf = 0;
|
||||
uint32 state_buf = 0;
|
||||
|
||||
uint32 num_svc_out = 0;
|
||||
|
||||
ENUM_SERVICES_STATUS *svc_buf = NULL;
|
||||
|
||||
if ( !hnd )
|
||||
return CAC_FAILURE;
|
||||
|
||||
if ( !hnd->_internal.ctx ) {
|
||||
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
if ( !op || !op->in.scm_hnd || !mem_ctx ) {
|
||||
hnd->status = NT_STATUS_INVALID_PARAMETER;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
|
||||
if ( !pipe_hnd ) {
|
||||
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
type_buf =
|
||||
( op->in.type !=
|
||||
0 ) ? op->in.
|
||||
type : ( SVCCTL_TYPE_DRIVER | SVCCTL_TYPE_WIN32 );
|
||||
state_buf = ( op->in.state != 0 ) ? op->in.state : SVCCTL_STATE_ALL;
|
||||
|
||||
err = rpccli_svcctl_enumerate_services( pipe_hnd, mem_ctx,
|
||||
op->in.scm_hnd, type_buf,
|
||||
state_buf, &num_svc_out,
|
||||
&svc_buf );
|
||||
hnd->status = werror_to_ntstatus( err );
|
||||
|
||||
if ( !NT_STATUS_IS_OK( hnd->status ) )
|
||||
return CAC_FAILURE;
|
||||
|
||||
op->out.services =
|
||||
cac_MakeServiceArray( mem_ctx, svc_buf, num_svc_out );
|
||||
|
||||
if ( !op->out.services ) {
|
||||
hnd->status = NT_STATUS_NO_MEMORY;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
TALLOC_FREE( svc_buf );
|
||||
|
||||
op->out.num_services = num_svc_out;
|
||||
|
||||
return CAC_SUCCESS;
|
||||
}
|
||||
|
||||
int cac_SvcOpenService( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
|
||||
struct SvcOpenService *op )
|
||||
{
|
||||
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||
WERROR err;
|
||||
|
||||
POLICY_HND *svc_hnd_out = NULL;
|
||||
|
||||
if ( !hnd )
|
||||
return CAC_FAILURE;
|
||||
|
||||
if ( !hnd->_internal.ctx ) {
|
||||
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
if ( !op || !op->in.scm_hnd || !op->in.name || !mem_ctx ) {
|
||||
hnd->status = NT_STATUS_INVALID_PARAMETER;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
|
||||
if ( !pipe_hnd ) {
|
||||
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
svc_hnd_out = talloc( mem_ctx, POLICY_HND );
|
||||
if ( !svc_hnd_out ) {
|
||||
hnd->status = NT_STATUS_NO_MEMORY;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
err = rpccli_svcctl_open_service( pipe_hnd, mem_ctx, op->in.scm_hnd,
|
||||
svc_hnd_out, op->in.name,
|
||||
op->in.access );
|
||||
hnd->status = werror_to_ntstatus( err );
|
||||
|
||||
if ( !NT_STATUS_IS_OK( hnd->status ) )
|
||||
return CAC_FAILURE;
|
||||
|
||||
op->out.svc_hnd = svc_hnd_out;
|
||||
|
||||
return CAC_SUCCESS;
|
||||
}
|
||||
|
||||
int cac_SvcControlService( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
|
||||
struct SvcControlService *op )
|
||||
{
|
||||
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||
WERROR err;
|
||||
|
||||
SERVICE_STATUS status_out;
|
||||
|
||||
if ( !hnd )
|
||||
return CAC_FAILURE;
|
||||
|
||||
if ( !hnd->_internal.ctx ) {
|
||||
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
if ( !op || !op->in.svc_hnd || !mem_ctx ) {
|
||||
hnd->status = NT_STATUS_INVALID_PARAMETER;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
if ( op->in.control < SVCCTL_CONTROL_STOP
|
||||
|| op->in.control > SVCCTL_CONTROL_SHUTDOWN ) {
|
||||
hnd->status = NT_STATUS_INVALID_PARAMETER;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
|
||||
if ( !pipe_hnd ) {
|
||||
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
err = rpccli_svcctl_control_service( pipe_hnd, mem_ctx,
|
||||
op->in.svc_hnd, op->in.control,
|
||||
&status_out );
|
||||
hnd->status = werror_to_ntstatus( err );
|
||||
|
||||
if ( !NT_STATUS_IS_OK( hnd->status ) )
|
||||
return CAC_FAILURE;
|
||||
|
||||
return CAC_SUCCESS;
|
||||
}
|
||||
|
||||
int cac_SvcGetStatus( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
|
||||
struct SvcGetStatus *op )
|
||||
{
|
||||
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||
WERROR err;
|
||||
|
||||
SERVICE_STATUS status_out;
|
||||
|
||||
if ( !hnd )
|
||||
return CAC_FAILURE;
|
||||
|
||||
if ( !hnd->_internal.ctx ) {
|
||||
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
if ( !op || !op->in.svc_hnd || !mem_ctx ) {
|
||||
hnd->status = NT_STATUS_INVALID_PARAMETER;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
|
||||
if ( !pipe_hnd ) {
|
||||
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
err = rpccli_svcctl_query_status( pipe_hnd, mem_ctx, op->in.svc_hnd,
|
||||
&status_out );
|
||||
hnd->status = werror_to_ntstatus( err );
|
||||
|
||||
if ( !NT_STATUS_IS_OK( hnd->status ) )
|
||||
return CAC_FAILURE;
|
||||
|
||||
op->out.status = status_out;
|
||||
|
||||
return CAC_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*Internal function - similar to code found in utils/net_rpc_service.c
|
||||
* Waits for a service to reach a specific state.
|
||||
* svc_hnd - Handle to the service
|
||||
* state - the state we are waiting for
|
||||
* timeout - number of seconds to wait
|
||||
* returns CAC_FAILURE if the state is never reached
|
||||
* or CAC_SUCCESS if the state is reached
|
||||
*/
|
||||
int cac_WaitForService( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
|
||||
POLICY_HND * svc_hnd, uint32 state, uint32 timeout,
|
||||
SERVICE_STATUS * status )
|
||||
{
|
||||
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||
|
||||
/*number of milliseconds we have spent */
|
||||
uint32 time_spent = 0;
|
||||
WERROR err;
|
||||
|
||||
if ( !hnd || !mem_ctx || !svc_hnd || !status )
|
||||
return CAC_FAILURE;
|
||||
|
||||
pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
|
||||
if ( !pipe_hnd ) {
|
||||
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
while ( status->state != state && time_spent < ( timeout * 1000000 )
|
||||
&& NT_STATUS_IS_OK( hnd->status ) ) {
|
||||
/*if this is the first call, then we _just_ got the status.. sleep now */
|
||||
usleep( WAIT_SLEEP_TIME );
|
||||
time_spent += WAIT_SLEEP_TIME;
|
||||
|
||||
err = rpccli_svcctl_query_status( pipe_hnd, mem_ctx, svc_hnd,
|
||||
status );
|
||||
hnd->status = werror_to_ntstatus( err );
|
||||
}
|
||||
|
||||
if ( status->state == state )
|
||||
return CAC_SUCCESS;
|
||||
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
int cac_SvcStartService( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
|
||||
struct SvcStartService *op )
|
||||
{
|
||||
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||
WERROR err;
|
||||
|
||||
SERVICE_STATUS status_buf;
|
||||
|
||||
if ( !hnd )
|
||||
return CAC_FAILURE;
|
||||
|
||||
if ( !hnd->_internal.ctx ) {
|
||||
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
if ( !op || !op->in.svc_hnd || !mem_ctx ) {
|
||||
hnd->status = NT_STATUS_INVALID_PARAMETER;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
if ( op->in.num_parms != 0 && op->in.parms == NULL ) {
|
||||
hnd->status = NT_STATUS_INVALID_PARAMETER;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
|
||||
if ( !pipe_hnd ) {
|
||||
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
err = rpccli_svcctl_start_service( pipe_hnd, mem_ctx, op->in.svc_hnd,
|
||||
( const char ** ) op->in.parms,
|
||||
op->in.num_parms );
|
||||
hnd->status = werror_to_ntstatus( err );
|
||||
|
||||
if ( !NT_STATUS_IS_OK( hnd->status ) )
|
||||
return CAC_FAILURE;
|
||||
|
||||
if ( op->in.timeout == 0 )
|
||||
return CAC_SUCCESS;
|
||||
|
||||
return cac_WaitForService( hnd, mem_ctx, op->in.svc_hnd,
|
||||
SVCCTL_RUNNING, op->in.timeout,
|
||||
&status_buf );
|
||||
}
|
||||
|
||||
int cac_SvcStopService( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
|
||||
struct SvcStopService *op )
|
||||
{
|
||||
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||
WERROR err;
|
||||
|
||||
SERVICE_STATUS status_out;
|
||||
|
||||
if ( !hnd )
|
||||
return CAC_FAILURE;
|
||||
|
||||
if ( !hnd->_internal.ctx ) {
|
||||
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
if ( !op || !op->in.svc_hnd || !mem_ctx ) {
|
||||
hnd->status = NT_STATUS_INVALID_PARAMETER;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
|
||||
if ( !pipe_hnd ) {
|
||||
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
err = rpccli_svcctl_control_service( pipe_hnd, mem_ctx,
|
||||
op->in.svc_hnd,
|
||||
SVCCTL_CONTROL_STOP,
|
||||
&status_out );
|
||||
hnd->status = werror_to_ntstatus( err );
|
||||
|
||||
if ( !NT_STATUS_IS_OK( hnd->status ) )
|
||||
return CAC_FAILURE;
|
||||
|
||||
op->out.status = status_out;
|
||||
|
||||
if ( op->in.timeout == 0 )
|
||||
return CAC_SUCCESS;
|
||||
|
||||
return cac_WaitForService( hnd, mem_ctx, op->in.svc_hnd,
|
||||
SVCCTL_STOPPED, op->in.timeout,
|
||||
&op->out.status );
|
||||
}
|
||||
|
||||
int cac_SvcPauseService( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
|
||||
struct SvcPauseService *op )
|
||||
{
|
||||
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||
WERROR err;
|
||||
|
||||
SERVICE_STATUS status_out;
|
||||
|
||||
if ( !hnd )
|
||||
return CAC_FAILURE;
|
||||
|
||||
if ( !hnd->_internal.ctx ) {
|
||||
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
if ( !op || !op->in.svc_hnd || !mem_ctx ) {
|
||||
hnd->status = NT_STATUS_INVALID_PARAMETER;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
|
||||
if ( !pipe_hnd ) {
|
||||
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
err = rpccli_svcctl_control_service( pipe_hnd, mem_ctx,
|
||||
op->in.svc_hnd,
|
||||
SVCCTL_CONTROL_PAUSE,
|
||||
&status_out );
|
||||
hnd->status = werror_to_ntstatus( err );
|
||||
|
||||
if ( !NT_STATUS_IS_OK( hnd->status ) )
|
||||
return CAC_FAILURE;
|
||||
|
||||
op->out.status = status_out;
|
||||
|
||||
if ( op->in.timeout == 0 )
|
||||
return CAC_SUCCESS;
|
||||
|
||||
return cac_WaitForService( hnd, mem_ctx, op->in.svc_hnd,
|
||||
SVCCTL_PAUSED, op->in.timeout,
|
||||
&op->out.status );
|
||||
}
|
||||
|
||||
int cac_SvcContinueService( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
|
||||
struct SvcContinueService *op )
|
||||
{
|
||||
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||
WERROR err;
|
||||
|
||||
SERVICE_STATUS status_out;
|
||||
|
||||
if ( !hnd )
|
||||
return CAC_FAILURE;
|
||||
|
||||
if ( !hnd->_internal.ctx ) {
|
||||
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
if ( !op || !op->in.svc_hnd || !mem_ctx ) {
|
||||
hnd->status = NT_STATUS_INVALID_PARAMETER;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
|
||||
if ( !pipe_hnd ) {
|
||||
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
err = rpccli_svcctl_control_service( pipe_hnd, mem_ctx,
|
||||
op->in.svc_hnd,
|
||||
SVCCTL_CONTROL_CONTINUE,
|
||||
&status_out );
|
||||
hnd->status = werror_to_ntstatus( err );
|
||||
|
||||
if ( !NT_STATUS_IS_OK( hnd->status ) )
|
||||
return CAC_FAILURE;
|
||||
|
||||
op->out.status = status_out;
|
||||
|
||||
if ( op->in.timeout == 0 )
|
||||
return CAC_SUCCESS;
|
||||
|
||||
return cac_WaitForService( hnd, mem_ctx, op->in.svc_hnd,
|
||||
SVCCTL_RUNNING, op->in.timeout,
|
||||
&op->out.status );
|
||||
}
|
||||
|
||||
int cac_SvcGetDisplayName( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
|
||||
struct SvcGetDisplayName *op )
|
||||
{
|
||||
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||
WERROR err;
|
||||
|
||||
fstring disp_name_out;
|
||||
|
||||
if ( !hnd )
|
||||
return CAC_FAILURE;
|
||||
|
||||
if ( !hnd->_internal.ctx ) {
|
||||
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
if ( !op || !op->in.svc_hnd || !mem_ctx ) {
|
||||
hnd->status = NT_STATUS_INVALID_PARAMETER;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
|
||||
if ( !pipe_hnd ) {
|
||||
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
err = rpccli_svcctl_get_dispname( pipe_hnd, mem_ctx, op->in.svc_hnd,
|
||||
disp_name_out );
|
||||
hnd->status = werror_to_ntstatus( err );
|
||||
|
||||
if ( !NT_STATUS_IS_OK( hnd->status ) )
|
||||
return CAC_FAILURE;
|
||||
|
||||
op->out.display_name = talloc_strdup( mem_ctx, disp_name_out );
|
||||
|
||||
if ( !op->out.display_name ) {
|
||||
hnd->status = NT_STATUS_NO_MEMORY;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
return CAC_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int cac_SvcGetServiceConfig( CacServerHandle * hnd, TALLOC_CTX * mem_ctx,
|
||||
struct SvcGetServiceConfig *op )
|
||||
{
|
||||
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||
WERROR err;
|
||||
|
||||
SERVICE_CONFIG config_out;
|
||||
|
||||
if ( !hnd )
|
||||
return CAC_FAILURE;
|
||||
|
||||
if ( !hnd->_internal.ctx ) {
|
||||
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
if ( !op || !op->in.svc_hnd || !mem_ctx ) {
|
||||
hnd->status = NT_STATUS_INVALID_PARAMETER;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
pipe_hnd = cac_GetPipe( hnd, PI_SVCCTL );
|
||||
if ( !pipe_hnd ) {
|
||||
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
err = rpccli_svcctl_query_config( pipe_hnd, mem_ctx, op->in.svc_hnd,
|
||||
&config_out );
|
||||
hnd->status = werror_to_ntstatus( err );
|
||||
|
||||
if ( !NT_STATUS_IS_OK( hnd->status ) )
|
||||
return CAC_FAILURE;
|
||||
|
||||
if ( !cac_InitCacServiceConfig
|
||||
( mem_ctx, &config_out, &op->out.config ) ) {
|
||||
hnd->status = NT_STATUS_NO_MEMORY;
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
return CAC_SUCCESS;
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,349 +0,0 @@
|
||||
|
||||
/*
|
||||
* Unix SMB/CIFS implementation.
|
||||
* MS-RPC client library implementation
|
||||
* Copyright (C) Chris Nicholls 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "libmsrpc.h"
|
||||
#include "libmsrpc_internal.h"
|
||||
#include "libsmbclient.h"
|
||||
#include "libsmb_internal.h"
|
||||
|
||||
int cac_InitHandleData( CacServerHandle * hnd );
|
||||
|
||||
/*this function is based on code found in smbc_init_context() (libsmb/libsmbclient.c)*/
|
||||
void cac_Init( int debug )
|
||||
{
|
||||
if ( debug < 0 || debug > 99 )
|
||||
debug = 0;
|
||||
|
||||
DEBUGLEVEL = debug;
|
||||
|
||||
setup_logging( "libmsrpc", True );
|
||||
}
|
||||
|
||||
int cac_InitHandleMem( CacServerHandle * hnd )
|
||||
{
|
||||
hnd->username = SMB_MALLOC_ARRAY( char, sizeof( fstring ) );
|
||||
|
||||
if ( !hnd->username )
|
||||
return CAC_FAILURE;
|
||||
|
||||
hnd->username[0] = '\0';
|
||||
|
||||
hnd->domain = SMB_MALLOC_ARRAY( char, sizeof( fstring ) );
|
||||
if ( !hnd->domain )
|
||||
return CAC_FAILURE;
|
||||
|
||||
hnd->domain[0] = '\0';
|
||||
|
||||
hnd->netbios_name = SMB_MALLOC_ARRAY( char, sizeof( fstring ) );
|
||||
if ( !hnd->netbios_name )
|
||||
return CAC_FAILURE;
|
||||
|
||||
hnd->netbios_name[0] = '\0';
|
||||
|
||||
hnd->password = SMB_MALLOC_ARRAY( char, sizeof( fstring ) );
|
||||
if ( !hnd->password )
|
||||
return CAC_FAILURE;
|
||||
|
||||
hnd->password[0] = '\0';
|
||||
|
||||
hnd->server = SMB_MALLOC_ARRAY( char, sizeof( fstring ) );
|
||||
if ( !hnd->server )
|
||||
return CAC_FAILURE;
|
||||
|
||||
hnd->server[0] = '\0';
|
||||
|
||||
return CAC_SUCCESS;
|
||||
}
|
||||
|
||||
CacServerHandle *cac_NewServerHandle( BOOL allocate_fields )
|
||||
{
|
||||
CacServerHandle *hnd;
|
||||
|
||||
hnd = SMB_MALLOC_P( CacServerHandle );
|
||||
|
||||
if ( !hnd ) {
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZERO_STRUCTP( hnd );
|
||||
|
||||
if ( allocate_fields == True ) {
|
||||
if ( !cac_InitHandleMem( hnd ) ) {
|
||||
SAFE_FREE( hnd );
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
hnd->_internal.ctx = smbc_new_context( );
|
||||
if ( !hnd->_internal.ctx ) {
|
||||
cac_FreeHandle( hnd );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
hnd->_internal.ctx->callbacks.auth_fn = cac_GetAuthDataFn;
|
||||
|
||||
/*add defaults */
|
||||
hnd->debug = 0;
|
||||
|
||||
/*start at the highest and it will fall down after trying the functions */
|
||||
hnd->_internal.srv_level = SRV_WIN_2K3;
|
||||
|
||||
hnd->_internal.user_supplied_ctx = False;
|
||||
|
||||
return hnd;
|
||||
}
|
||||
|
||||
int cac_InitHandleData( CacServerHandle * hnd )
|
||||
{
|
||||
/*store any automatically initialized values */
|
||||
if ( !hnd->netbios_name ) {
|
||||
hnd->netbios_name =
|
||||
SMB_STRDUP( hnd->_internal.ctx->netbios_name );
|
||||
} else if ( hnd->netbios_name[0] == '\0' ) {
|
||||
strncpy( hnd->netbios_name, hnd->_internal.ctx->netbios_name,
|
||||
sizeof( fstring ) );
|
||||
}
|
||||
|
||||
if ( !hnd->username ) {
|
||||
hnd->username = SMB_STRDUP( hnd->_internal.ctx->user );
|
||||
} else if ( hnd->username[0] == '\0' ) {
|
||||
strncpy( hnd->username, hnd->_internal.ctx->user,
|
||||
sizeof( fstring ) );
|
||||
}
|
||||
|
||||
if ( !hnd->domain ) {
|
||||
hnd->domain = SMB_STRDUP( hnd->_internal.ctx->workgroup );
|
||||
} else if ( hnd->domain[0] == '\0' ) {
|
||||
strncpy( hnd->domain, hnd->_internal.ctx->workgroup,
|
||||
sizeof( fstring ) );
|
||||
}
|
||||
|
||||
return CAC_SUCCESS;
|
||||
}
|
||||
|
||||
void cac_SetAuthDataFn( CacServerHandle * hnd, smbc_get_auth_data_fn auth_fn )
|
||||
{
|
||||
hnd->_internal.ctx->callbacks.auth_fn = auth_fn;
|
||||
}
|
||||
|
||||
void cac_SetSmbcContext( CacServerHandle * hnd, SMBCCTX * ctx )
|
||||
{
|
||||
|
||||
SAFE_FREE( hnd->_internal.ctx );
|
||||
|
||||
hnd->_internal.user_supplied_ctx = True;
|
||||
|
||||
hnd->_internal.ctx = ctx;
|
||||
|
||||
/*_try_ to avoid any problems that might occur if cac_Connect() isn't called*/
|
||||
/*cac_InitHandleData(hnd); */
|
||||
}
|
||||
|
||||
/*used internally*/
|
||||
SMBCSRV *cac_GetServer( CacServerHandle * hnd )
|
||||
{
|
||||
SMBCSRV *srv;
|
||||
|
||||
if ( !hnd || !hnd->_internal.ctx ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
srv = smbc_attr_server( hnd->_internal.ctx, hnd->server, "IPC$",
|
||||
hnd->domain, hnd->username, hnd->password,
|
||||
NULL );
|
||||
if ( !srv ) {
|
||||
hnd->status = NT_STATUS_UNSUCCESSFUL;
|
||||
DEBUG( 1,
|
||||
( "cac_GetServer: Could not find server connection.\n" ) );
|
||||
}
|
||||
|
||||
return srv;
|
||||
}
|
||||
|
||||
|
||||
int cac_Connect( CacServerHandle * hnd, const char *srv )
|
||||
{
|
||||
if ( !hnd ) {
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
/*these values should be initialized by the user */
|
||||
if ( !hnd->server && !srv ) {
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
/*change the server name in the server handle if necessary */
|
||||
if ( srv && hnd->server && strcmp( hnd->server, srv ) == 0 ) {
|
||||
SAFE_FREE( hnd->server );
|
||||
hnd->server = SMB_STRDUP( srv );
|
||||
}
|
||||
|
||||
|
||||
/*first see if the context has already been setup */
|
||||
if ( !( hnd->_internal.ctx->internal->_initialized ) ) {
|
||||
hnd->_internal.ctx->debug = hnd->debug;
|
||||
|
||||
/*initialize the context */
|
||||
if ( !smbc_init_context( hnd->_internal.ctx ) ) {
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
/*copy any uninitialized values out of the smbc context into the handle */
|
||||
if ( !cac_InitHandleData( hnd ) ) {
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
DEBUG( 3, ( "cac_Connect: Username: %s\n", hnd->username ) );
|
||||
DEBUG( 3, ( "cac_Connect: Domain: %s\n", hnd->domain ) );
|
||||
DEBUG( 3, ( "cac_Connect: Netbios Name: %s\n", hnd->netbios_name ) );
|
||||
|
||||
if ( !cac_GetServer( hnd ) ) {
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
return CAC_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void cac_FreeHandle( CacServerHandle * hnd )
|
||||
{
|
||||
if ( !hnd )
|
||||
return;
|
||||
|
||||
/*only free the context if we created it */
|
||||
if ( !hnd->_internal.user_supplied_ctx ) {
|
||||
smbc_free_context( hnd->_internal.ctx, True );
|
||||
}
|
||||
|
||||
SAFE_FREE( hnd->netbios_name );
|
||||
SAFE_FREE( hnd->domain );
|
||||
SAFE_FREE( hnd->username );
|
||||
SAFE_FREE( hnd->password );
|
||||
SAFE_FREE( hnd->server );
|
||||
SAFE_FREE( hnd );
|
||||
|
||||
}
|
||||
|
||||
void cac_InitCacTime( CacTime * cactime, NTTIME nttime )
|
||||
{
|
||||
float high, low;
|
||||
uint32 sec;
|
||||
|
||||
if ( !cactime )
|
||||
return;
|
||||
|
||||
ZERO_STRUCTP( cactime );
|
||||
|
||||
/*this code is taken from display_time() found in rpcclient/cmd_samr.c */
|
||||
if ( nttime == 0 )
|
||||
return;
|
||||
|
||||
if ( nttime == 0x80000000000000LL )
|
||||
return;
|
||||
|
||||
high = 65536;
|
||||
high = high / 10000;
|
||||
high = high * 65536;
|
||||
high = high / 1000;
|
||||
high = high * ( ~( nttime >> 32 ) );
|
||||
|
||||
low = ~( nttime & 0xFFFFFFFF );
|
||||
low = low / ( 1000 * 1000 * 10 );
|
||||
|
||||
sec = high + low;
|
||||
|
||||
cactime->days = sec / ( 60 * 60 * 24 );
|
||||
cactime->hours =
|
||||
( sec - ( cactime->days * 60 * 60 * 24 ) ) / ( 60 * 60 );
|
||||
cactime->minutes =
|
||||
( sec - ( cactime->days * 60 * 60 * 24 ) -
|
||||
( cactime->hours * 60 * 60 ) ) / 60;
|
||||
cactime->seconds =
|
||||
sec - ( cactime->days * 60 * 60 * 24 ) -
|
||||
( cactime->hours * 60 * 60 ) - ( cactime->minutes * 60 );
|
||||
}
|
||||
|
||||
void cac_GetAuthDataFn( const char *pServer,
|
||||
const char *pShare,
|
||||
char *pWorkgroup,
|
||||
int maxLenWorkgroup,
|
||||
char *pUsername,
|
||||
int maxLenUsername,
|
||||
char *pPassword, int maxLenPassword )
|
||||
{
|
||||
char temp[sizeof( fstring )];
|
||||
|
||||
static char authUsername[sizeof( fstring )];
|
||||
static char authWorkgroup[sizeof( fstring )];
|
||||
static char authPassword[sizeof( fstring )];
|
||||
static char authSet = 0;
|
||||
|
||||
char *pass = NULL;
|
||||
|
||||
|
||||
if ( authSet ) {
|
||||
strncpy( pWorkgroup, authWorkgroup, maxLenWorkgroup - 1 );
|
||||
strncpy( pUsername, authUsername, maxLenUsername - 1 );
|
||||
strncpy( pPassword, authPassword, maxLenPassword - 1 );
|
||||
} else {
|
||||
d_printf( "Domain: [%s] ", pWorkgroup );
|
||||
fgets( temp, sizeof( fstring ), stdin );
|
||||
|
||||
if ( temp[strlen( temp ) - 1] == '\n' ) { /* A new line? */
|
||||
temp[strlen( temp ) - 1] = '\0';
|
||||
}
|
||||
|
||||
|
||||
if ( temp[0] != '\0' ) {
|
||||
strncpy( pWorkgroup, temp, maxLenWorkgroup - 1 );
|
||||
strncpy( authWorkgroup, temp, maxLenWorkgroup - 1 );
|
||||
}
|
||||
|
||||
d_printf( "Username: [%s] ", pUsername );
|
||||
fgets( temp, sizeof( fstring ), stdin );
|
||||
|
||||
if ( temp[strlen( temp ) - 1] == '\n' ) { /* A new line? */
|
||||
temp[strlen( temp ) - 1] = '\0';
|
||||
}
|
||||
|
||||
if ( temp[0] != '\0' ) {
|
||||
strncpy( pUsername, temp, maxLenUsername - 1 );
|
||||
strncpy( authUsername, pUsername,
|
||||
maxLenUsername - 1 );
|
||||
}
|
||||
|
||||
pass = getpass( "Password: " );
|
||||
if ( pass )
|
||||
fstrcpy( temp, pass );
|
||||
if ( temp[strlen( temp ) - 1] == '\n' ) { /* A new line? */
|
||||
temp[strlen( temp ) - 1] = '\0';
|
||||
}
|
||||
if ( temp[0] != '\0' ) {
|
||||
strncpy( pPassword, temp, maxLenPassword - 1 );
|
||||
strncpy( authPassword, pPassword,
|
||||
maxLenPassword - 1 );
|
||||
}
|
||||
authSet = 1;
|
||||
}
|
||||
}
|
@ -1,775 +0,0 @@
|
||||
|
||||
/*
|
||||
* Unix SMB/CIFS implementation.
|
||||
* MS-RPC client internal functions
|
||||
* Copyright (C) Chris Nicholls 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "libmsrpc.h"
|
||||
#include "libmsrpc_internal.h"
|
||||
|
||||
char *cac_unistr_to_str( TALLOC_CTX * mem_ctx, uint16 * src, int num_bytes );
|
||||
char *talloc_unistr2_to_ascii( TALLOC_CTX * mem_ctx, UNISTR2 str );
|
||||
char *cac_unistr_ascii( TALLOC_CTX * mem_ctx, UNISTR src );
|
||||
|
||||
/*used to get a struct rpc_pipe_client* to be passed into rpccli* calls*/
|
||||
struct rpc_pipe_client *cac_GetPipe( CacServerHandle * hnd, int pi_idx )
|
||||
{
|
||||
SMBCSRV *srv = NULL;
|
||||
struct rpc_pipe_client *pipe_hnd = NULL;
|
||||
|
||||
if ( !hnd ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( hnd->_internal.pipes[pi_idx] == False ) {
|
||||
hnd->status = NT_STATUS_INVALID_HANDLE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
srv = cac_GetServer( hnd );
|
||||
if ( !srv ) {
|
||||
hnd->status = NT_STATUS_INVALID_CONNECTION;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pipe_hnd = srv->cli->pipe_list;
|
||||
|
||||
while ( pipe_hnd != NULL && pipe_hnd->pipe_idx != pi_idx ) {
|
||||
pipe_hnd = pipe_hnd->next;
|
||||
}
|
||||
|
||||
return pipe_hnd;
|
||||
}
|
||||
|
||||
/*takes a string like HKEY_LOCAL_MACHINE\HARDWARE\ACPI and returns the reg_type code and then a pointer to the start of the path (HARDWARE)*/
|
||||
int cac_ParseRegPath( char *path, uint32 * reg_type, char **key_name )
|
||||
{
|
||||
|
||||
if ( !path )
|
||||
return CAC_FAILURE;
|
||||
|
||||
if ( strncmp( path, "HKLM", 4 ) == 0 ) {
|
||||
*reg_type = HKEY_LOCAL_MACHINE;
|
||||
*key_name = ( path[4] == '\\' ) ? path + 5 : NULL;
|
||||
} else if ( strncmp( path, "HKEY_LOCAL_MACHINE", 18 ) == 0 ) {
|
||||
*reg_type = HKEY_LOCAL_MACHINE;
|
||||
*key_name = ( path[18] == '\\' ) ? path + 19 : NULL;
|
||||
} else if ( strncmp( path, "HKCR", 4 ) == 0 ) {
|
||||
*reg_type = HKEY_CLASSES_ROOT;
|
||||
*key_name = ( path[4] == '\\' ) ? path + 5 : NULL;
|
||||
} else if ( strncmp( path, "HKEY_CLASSES_ROOT", 17 ) == 0 ) {
|
||||
*reg_type = HKEY_CLASSES_ROOT;
|
||||
*key_name = ( path[17] == '\\' ) ? path + 18 : NULL;
|
||||
} else if ( strncmp( path, "HKU", 3 ) == 0 ) {
|
||||
*reg_type = HKEY_USERS;
|
||||
*key_name = ( path[3] == '\\' ) ? path + 4 : NULL;
|
||||
} else if ( strncmp( path, "HKEY_USERS", 10 ) == 0 ) {
|
||||
*reg_type = HKEY_USERS;
|
||||
*key_name = ( path[10] == '\\' ) ? path + 11 : NULL;
|
||||
} else if ( strncmp( path, "HKPD", 4 ) == 0 ) {
|
||||
*reg_type = HKEY_PERFORMANCE_DATA;
|
||||
*key_name = ( path[4] == '\\' ) ? path + 5 : NULL;
|
||||
} else if ( strncmp( path, "HKEY_PERFORMANCE_DATA", 21 ) == 0 ) {
|
||||
*reg_type = HKEY_PERFORMANCE_DATA;
|
||||
*key_name = ( path[21] == '\\' ) ? path + 22 : NULL;
|
||||
} else {
|
||||
return CAC_FAILURE;
|
||||
}
|
||||
|
||||
return CAC_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RPC_DATA_BLOB *cac_MakeRpcDataBlob( TALLOC_CTX * mem_ctx, uint32 data_type,
|
||||
REG_VALUE_DATA data )
|
||||
{
|
||||
RPC_DATA_BLOB *blob = NULL;
|
||||
int i;
|
||||
uint32 size = 0;
|
||||
uint8 *multi = NULL;
|
||||
uint32 multi_idx = 0;
|
||||
|
||||
blob = talloc( mem_ctx, RPC_DATA_BLOB );
|
||||
|
||||
if ( !blob ) {
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch ( data_type ) {
|
||||
case REG_SZ:
|
||||
init_rpc_blob_str( blob, data.reg_sz,
|
||||
strlen( data.reg_sz ) + 1 );
|
||||
break;
|
||||
|
||||
case REG_EXPAND_SZ:
|
||||
init_rpc_blob_str( blob, data.reg_expand_sz,
|
||||
strlen( data.reg_sz ) + 1 );
|
||||
break;
|
||||
|
||||
case REG_BINARY:
|
||||
init_rpc_blob_bytes( blob, data.reg_binary.data,
|
||||
data.reg_binary.data_length );
|
||||
break;
|
||||
|
||||
case REG_DWORD:
|
||||
init_rpc_blob_uint32( blob, data.reg_dword );
|
||||
break;
|
||||
|
||||
case REG_DWORD_BIG_ENDIAN:
|
||||
init_rpc_blob_uint32( blob, data.reg_dword_be );
|
||||
break;
|
||||
|
||||
case REG_MULTI_SZ:
|
||||
/*need to find the size */
|
||||
for ( i = 0; i < data.reg_multi_sz.num_strings; i++ ) {
|
||||
size += strlen( data.reg_multi_sz.strings[i] ) + 1;
|
||||
}
|
||||
|
||||
/**need a whole bunch of unicode strings in a row (seperated by null characters), with an extra null-character on the end*/
|
||||
|
||||
multi = TALLOC_ZERO_ARRAY( mem_ctx, uint8, ( size + 1 ) * 2 ); /*size +1 for the extra null character */
|
||||
if ( !multi ) {
|
||||
errno = ENOMEM;
|
||||
break;
|
||||
}
|
||||
|
||||
/*do it using rpcstr_push() */
|
||||
multi_idx = 0;
|
||||
for ( i = 0; i < data.reg_multi_sz.num_strings; i++ ) {
|
||||
size_t len =
|
||||
strlen( data.reg_multi_sz.strings[i] ) + 1;
|
||||
|
||||
rpcstr_push( ( multi + multi_idx ),
|
||||
data.reg_multi_sz.strings[i], len * 2,
|
||||
STR_TERMINATE );
|
||||
|
||||
/* x2 becuase it is a uint8 buffer */
|
||||
multi_idx += len * 2;
|
||||
}
|
||||
|
||||
/*now initialize the buffer as binary data */
|
||||
init_rpc_blob_bytes( blob, multi, ( size + 1 ) * 2 );
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
TALLOC_FREE( blob );
|
||||
blob = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( !( blob->buffer ) ) {
|
||||
TALLOC_FREE( blob );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return blob;
|
||||
}
|
||||
|
||||
/*turns a string in a uint16 array to a char array*/
|
||||
char *cac_unistr_to_str( TALLOC_CTX * mem_ctx, uint16 * src, int num_bytes )
|
||||
{
|
||||
char *buf;
|
||||
|
||||
int i = 0;
|
||||
|
||||
uint32 str_len = 0;
|
||||
|
||||
/*don't allocate more space than we need */
|
||||
while ( ( str_len ) < num_bytes / 2 && src[str_len] != 0x0000 )
|
||||
str_len++;
|
||||
|
||||
/*need room for a '\0' */
|
||||
str_len++;
|
||||
|
||||
buf = TALLOC_ARRAY( mem_ctx, char, str_len );
|
||||
|
||||
if ( !buf ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for ( i = 0; i < num_bytes / 2; i++ ) {
|
||||
buf[i] = ( ( char * ) src )[2 * i];
|
||||
}
|
||||
|
||||
buf[str_len - 1] = '\0';
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
REG_VALUE_DATA *cac_MakeRegValueData( TALLOC_CTX * mem_ctx, uint32 data_type,
|
||||
REGVAL_BUFFER buf )
|
||||
{
|
||||
REG_VALUE_DATA *data;
|
||||
|
||||
uint32 i;
|
||||
|
||||
/*all of the following used for MULTI_SZ data */
|
||||
uint32 size = 0;
|
||||
uint32 len = 0;
|
||||
uint32 multi_idx = 0;
|
||||
uint32 num_strings = 0;
|
||||
char **strings = NULL;
|
||||
|
||||
data = talloc( mem_ctx, REG_VALUE_DATA );
|
||||
if ( !data ) {
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch ( data_type ) {
|
||||
case REG_SZ:
|
||||
data->reg_sz =
|
||||
cac_unistr_to_str( mem_ctx, buf.buffer, buf.buf_len );
|
||||
if ( !data->reg_sz ) {
|
||||
TALLOC_FREE( data );
|
||||
errno = ENOMEM;
|
||||
data = NULL;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case REG_EXPAND_SZ:
|
||||
data->reg_expand_sz =
|
||||
cac_unistr_to_str( mem_ctx, buf.buffer, buf.buf_len );
|
||||
|
||||
if ( !data->reg_expand_sz ) {
|
||||
TALLOC_FREE( data );
|
||||
errno = ENOMEM;
|
||||
data = NULL;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case REG_BINARY:
|
||||
size = buf.buf_len;
|
||||
|
||||
data->reg_binary.data_length = size;
|
||||
|
||||
if (size) {
|
||||
data->reg_binary.data =
|
||||
( uint8 * ) TALLOC_MEMDUP( mem_ctx, buf.buffer, size );
|
||||
if ( !data->reg_binary.data ) {
|
||||
TALLOC_FREE( data );
|
||||
errno = ENOMEM;
|
||||
data = NULL;
|
||||
}
|
||||
} else {
|
||||
data->reg_binary.data = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case REG_DWORD:
|
||||
data->reg_dword = *( ( uint32 * ) buf.buffer );
|
||||
break;
|
||||
|
||||
case REG_DWORD_BIG_ENDIAN:
|
||||
data->reg_dword_be = *( ( uint32 * ) buf.buffer );
|
||||
break;
|
||||
|
||||
case REG_MULTI_SZ:
|
||||
size = buf.buf_len;
|
||||
|
||||
/*find out how many strings there are. size is # of bytes and we want to work uint16 */
|
||||
for ( i = 0; i < ( size / 2 - 1 ); i++ ) {
|
||||
if ( buf.buffer[i] == 0x0000 )
|
||||
num_strings++;
|
||||
|
||||
/*buffer is suppsed to be terminated with \0\0, but it might not be */
|
||||
if ( buf.buffer[i] == 0x0000
|
||||
&& buf.buffer[i + 1] == 0x0000 )
|
||||
break;
|
||||
}
|
||||
|
||||
if (num_strings) {
|
||||
strings = TALLOC_ARRAY( mem_ctx, char *, num_strings );
|
||||
|
||||
if ( !strings ) {
|
||||
errno = ENOMEM;
|
||||
TALLOC_FREE( data );
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
strings = NULL;
|
||||
}
|
||||
|
||||
if ( num_strings == 0 ) /*then our work here is done */
|
||||
break;
|
||||
|
||||
for ( i = 0; i < num_strings; i++ ) {
|
||||
/*find out how many characters are in this string */
|
||||
len = 0;
|
||||
/*make sure we don't go past the end of the buffer and keep looping until we have a uni \0 */
|
||||
while ( multi_idx + len < size / 2
|
||||
&& buf.buffer[multi_idx + len] != 0x0000 )
|
||||
len++;
|
||||
|
||||
/*stay aware of the \0\0 */
|
||||
len++;
|
||||
|
||||
strings[i] = TALLOC_ZERO_ARRAY( mem_ctx, char, len );
|
||||
|
||||
/*pull out the unicode string */
|
||||
rpcstr_pull( strings[i], ( buf.buffer + multi_idx ),
|
||||
len, -1, STR_TERMINATE );
|
||||
|
||||
/*keep track of where we are in the bigger array */
|
||||
multi_idx += len;
|
||||
}
|
||||
|
||||
data->reg_multi_sz.num_strings = num_strings;
|
||||
data->reg_multi_sz.strings = strings;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
TALLOC_FREE( data );
|
||||
data = NULL;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
SAM_USERINFO_CTR *cac_MakeUserInfoCtr( TALLOC_CTX * mem_ctx,
|
||||
CacUserInfo * info )
|
||||
{
|
||||
SAM_USERINFO_CTR *ctr = NULL;
|
||||
|
||||
/*the flags we are 'setting'- include/passdb.h */
|
||||
uint32 flags =
|
||||
ACCT_USERNAME | ACCT_FULL_NAME | ACCT_PRIMARY_GID |
|
||||
ACCT_DESCRIPTION | ACCT_COMMENT | ACCT_HOME_DIR |
|
||||
ACCT_HOME_DRIVE | ACCT_LOGON_SCRIPT | ACCT_PROFILE |
|
||||
ACCT_WORKSTATIONS | ACCT_FLAGS;
|
||||
|
||||
NTTIME logon_time;
|
||||
NTTIME logoff_time;
|
||||
NTTIME kickoff_time;
|
||||
NTTIME pass_last_set_time;
|
||||
NTTIME pass_can_change_time;
|
||||
NTTIME pass_must_change_time;
|
||||
|
||||
UNISTR2 user_name;
|
||||
UNISTR2 full_name;
|
||||
UNISTR2 home_dir;
|
||||
UNISTR2 dir_drive;
|
||||
UNISTR2 log_scr;
|
||||
UNISTR2 prof_path;
|
||||
UNISTR2 desc;
|
||||
UNISTR2 wkstas;
|
||||
UNISTR2 mung_dial;
|
||||
UNISTR2 unk;
|
||||
|
||||
ctr = talloc( mem_ctx, SAM_USERINFO_CTR );
|
||||
if ( !ctr )
|
||||
return NULL;
|
||||
|
||||
ZERO_STRUCTP( ctr->info.id23 );
|
||||
|
||||
ctr->info.id21 = talloc( mem_ctx, SAM_USER_INFO_21 );
|
||||
if ( !ctr->info.id21 )
|
||||
return NULL;
|
||||
|
||||
ctr->switch_value = 21;
|
||||
|
||||
ZERO_STRUCTP( ctr->info.id21 );
|
||||
|
||||
unix_to_nt_time( &logon_time, info->logon_time );
|
||||
unix_to_nt_time( &logoff_time, info->logoff_time );
|
||||
unix_to_nt_time( &kickoff_time, info->kickoff_time );
|
||||
unix_to_nt_time( &pass_last_set_time, info->pass_last_set_time );
|
||||
unix_to_nt_time( &pass_can_change_time, info->pass_can_change_time );
|
||||
unix_to_nt_time( &pass_must_change_time,
|
||||
info->pass_must_change_time );
|
||||
|
||||
/*initialize the strings */
|
||||
init_unistr2( &user_name, info->username, UNI_STR_TERMINATE );
|
||||
init_unistr2( &full_name, info->full_name, UNI_STR_TERMINATE );
|
||||
init_unistr2( &home_dir, info->home_dir, UNI_STR_TERMINATE );
|
||||
init_unistr2( &dir_drive, info->home_drive, UNI_STR_TERMINATE );
|
||||
init_unistr2( &log_scr, info->logon_script, UNI_STR_TERMINATE );
|
||||
init_unistr2( &prof_path, info->profile_path, UNI_STR_TERMINATE );
|
||||
init_unistr2( &desc, info->description, UNI_STR_TERMINATE );
|
||||
init_unistr2( &wkstas, info->workstations, UNI_STR_TERMINATE );
|
||||
init_unistr2( &unk, "\0", UNI_STR_TERMINATE );
|
||||
init_unistr2( &mung_dial, info->dial, UNI_STR_TERMINATE );
|
||||
|
||||
/*manually set passmustchange */
|
||||
ctr->info.id21->passmustchange =
|
||||
( info->pass_must_change ) ? 0x01 : 0x00;
|
||||
|
||||
init_sam_user_info21W( ctr->info.id21, &logon_time, &logoff_time, &kickoff_time, &pass_last_set_time, &pass_can_change_time, &pass_must_change_time, &user_name, &full_name, &home_dir, &dir_drive, &log_scr, &prof_path, &desc, &wkstas, &unk, &mung_dial, info->lm_password, info->nt_password, info->rid, info->group_rid, info->acb_mask, flags, 168, /*logon divs */
|
||||
info->logon_hours,
|
||||
info->bad_passwd_count, info->logon_count );
|
||||
|
||||
return ctr;
|
||||
|
||||
}
|
||||
|
||||
char *talloc_unistr2_to_ascii( TALLOC_CTX * mem_ctx, UNISTR2 str )
|
||||
{
|
||||
char *buf = NULL;
|
||||
|
||||
if ( !mem_ctx )
|
||||
return NULL;
|
||||
|
||||
buf = TALLOC_ARRAY( mem_ctx, char, ( str.uni_str_len + 1 ) );
|
||||
if ( !buf )
|
||||
return NULL;
|
||||
|
||||
unistr2_to_ascii( buf, &str, str.uni_str_len + 1 );
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
CacUserInfo *cac_MakeUserInfo( TALLOC_CTX * mem_ctx, SAM_USERINFO_CTR * ctr )
|
||||
{
|
||||
CacUserInfo *info = NULL;
|
||||
SAM_USER_INFO_21 *id21 = NULL;
|
||||
|
||||
if ( !ctr || ctr->switch_value != 21 )
|
||||
return NULL;
|
||||
|
||||
info = talloc( mem_ctx, CacUserInfo );
|
||||
if ( !info )
|
||||
return NULL;
|
||||
|
||||
id21 = ctr->info.id21;
|
||||
|
||||
ZERO_STRUCTP( info );
|
||||
|
||||
info->logon_time = nt_time_to_unix( id21->logon_time );
|
||||
info->logoff_time = nt_time_to_unix( id21->logoff_time );
|
||||
info->kickoff_time = nt_time_to_unix( id21->kickoff_time );
|
||||
info->pass_last_set_time =
|
||||
nt_time_to_unix( id21->pass_last_set_time );
|
||||
info->pass_can_change_time =
|
||||
nt_time_to_unix( id21->pass_can_change_time );
|
||||
info->pass_must_change_time =
|
||||
nt_time_to_unix( id21->pass_must_change_time );
|
||||
|
||||
info->username =
|
||||
talloc_unistr2_to_ascii( mem_ctx, id21->uni_user_name );
|
||||
if ( !info->username )
|
||||
return NULL;
|
||||
|
||||
info->full_name =
|
||||
talloc_unistr2_to_ascii( mem_ctx, id21->uni_full_name );
|
||||
if ( !info->full_name )
|
||||
return NULL;
|
||||
|
||||
info->home_dir =
|
||||
talloc_unistr2_to_ascii( mem_ctx, id21->uni_home_dir );
|
||||
if ( !info->home_dir )
|
||||
return NULL;
|
||||
|
||||
info->home_drive =
|
||||
talloc_unistr2_to_ascii( mem_ctx, id21->uni_dir_drive );
|
||||
if ( !info->home_drive )
|
||||
return NULL;
|
||||
|
||||
info->logon_script =
|
||||
talloc_unistr2_to_ascii( mem_ctx, id21->uni_logon_script );
|
||||
if ( !info->logon_script )
|
||||
return NULL;
|
||||
|
||||
info->profile_path =
|
||||
talloc_unistr2_to_ascii( mem_ctx, id21->uni_profile_path );
|
||||
if ( !info->profile_path )
|
||||
return NULL;
|
||||
|
||||
info->description =
|
||||
talloc_unistr2_to_ascii( mem_ctx, id21->uni_acct_desc );
|
||||
if ( !info->description )
|
||||
return NULL;
|
||||
|
||||
info->workstations =
|
||||
talloc_unistr2_to_ascii( mem_ctx, id21->uni_workstations );
|
||||
if ( !info->workstations )
|
||||
return NULL;
|
||||
|
||||
info->dial =
|
||||
talloc_unistr2_to_ascii( mem_ctx, id21->uni_munged_dial );
|
||||
if ( !info->dial )
|
||||
return NULL;
|
||||
|
||||
info->rid = id21->user_rid;
|
||||
info->group_rid = id21->group_rid;
|
||||
info->acb_mask = id21->acb_info;
|
||||
info->bad_passwd_count = id21->bad_password_count;
|
||||
info->logon_count = id21->logon_count;
|
||||
|
||||
memcpy( info->nt_password, id21->nt_pwd, 8 );
|
||||
memcpy( info->lm_password, id21->lm_pwd, 8 );
|
||||
|
||||
info->logon_hours =
|
||||
( LOGON_HRS * ) TALLOC_MEMDUP( mem_ctx, &( id21->logon_hrs ),
|
||||
sizeof( LOGON_HRS ) );
|
||||
if ( !info->logon_hours )
|
||||
return NULL;
|
||||
|
||||
info->pass_must_change = ( id21->passmustchange ) ? True : False;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
CacGroupInfo *cac_MakeGroupInfo( TALLOC_CTX * mem_ctx, GROUP_INFO_CTR * ctr )
|
||||
{
|
||||
CacGroupInfo *info = NULL;
|
||||
|
||||
if ( !mem_ctx || !ctr || ctr->switch_value1 != 1 )
|
||||
return NULL;
|
||||
|
||||
info = talloc( mem_ctx, CacGroupInfo );
|
||||
if ( !info )
|
||||
return NULL;
|
||||
|
||||
info->name =
|
||||
talloc_unistr2_to_ascii( mem_ctx,
|
||||
ctr->group.info1.uni_acct_name );
|
||||
if ( !info->name )
|
||||
return NULL;
|
||||
|
||||
info->description =
|
||||
talloc_unistr2_to_ascii( mem_ctx,
|
||||
ctr->group.info1.uni_acct_desc );
|
||||
if ( !info->description )
|
||||
return NULL;
|
||||
|
||||
info->num_members = ctr->group.info1.num_members;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
GROUP_INFO_CTR *cac_MakeGroupInfoCtr( TALLOC_CTX * mem_ctx,
|
||||
CacGroupInfo * info )
|
||||
{
|
||||
GROUP_INFO_CTR *ctr = NULL;
|
||||
|
||||
if ( !mem_ctx || !info )
|
||||
return NULL;
|
||||
|
||||
ctr = talloc( mem_ctx, GROUP_INFO_CTR );
|
||||
if ( !ctr )
|
||||
return NULL;
|
||||
|
||||
ctr->switch_value1 = 1;
|
||||
|
||||
init_samr_group_info1( &( ctr->group.info1 ), info->name,
|
||||
info->description, info->num_members );
|
||||
|
||||
return ctr;
|
||||
}
|
||||
|
||||
CacAliasInfo *cac_MakeAliasInfo( TALLOC_CTX * mem_ctx, ALIAS_INFO_CTR ctr )
|
||||
{
|
||||
CacGroupInfo *info = NULL;
|
||||
|
||||
if ( !mem_ctx || ctr.level != 1 )
|
||||
return NULL;
|
||||
|
||||
info = talloc( mem_ctx, CacAliasInfo );
|
||||
if ( !info )
|
||||
return NULL;
|
||||
|
||||
info->name =
|
||||
talloc_unistr2_to_ascii( mem_ctx,
|
||||
*( ctr.alias.info1.name.string ) );
|
||||
if ( !info->name )
|
||||
return NULL;
|
||||
|
||||
info->description =
|
||||
talloc_unistr2_to_ascii( mem_ctx,
|
||||
*( ctr.alias.info1.description.
|
||||
string ) );
|
||||
if ( !info->name )
|
||||
return NULL;
|
||||
|
||||
info->num_members = ctr.alias.info1.num_member;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
ALIAS_INFO_CTR *cac_MakeAliasInfoCtr( TALLOC_CTX * mem_ctx,
|
||||
CacAliasInfo * info )
|
||||
{
|
||||
ALIAS_INFO_CTR *ctr = NULL;
|
||||
|
||||
if ( !mem_ctx || !info )
|
||||
return NULL;
|
||||
|
||||
ctr = talloc( mem_ctx, ALIAS_INFO_CTR );
|
||||
if ( !ctr )
|
||||
return NULL;
|
||||
|
||||
ctr->level = 1;
|
||||
|
||||
init_samr_alias_info1( &( ctr->alias.info1 ), info->name,
|
||||
info->num_members, info->description );
|
||||
|
||||
return ctr;
|
||||
}
|
||||
|
||||
CacDomainInfo *cac_MakeDomainInfo( TALLOC_CTX * mem_ctx,
|
||||
SAM_UNK_INFO_1 * info1,
|
||||
SAM_UNK_INFO_2 * info2,
|
||||
SAM_UNK_INFO_12 * info12 )
|
||||
{
|
||||
CacDomainInfo *info = NULL;
|
||||
|
||||
if ( !mem_ctx || !info1 || !info2 || !info12 )
|
||||
return NULL;
|
||||
|
||||
info = talloc( mem_ctx, CacDomainInfo );
|
||||
if ( !info )
|
||||
return NULL;
|
||||
|
||||
info->min_pass_length = info1->min_length_password;
|
||||
info->pass_history = info1->password_history;
|
||||
|
||||
cac_InitCacTime( &( info->expire ), info1->expire );
|
||||
cac_InitCacTime( &( info->min_pass_age ), info1->min_passwordage );
|
||||
|
||||
info->server_role = info2->server_role;
|
||||
info->num_users = info2->num_domain_usrs;
|
||||
info->num_domain_groups = info2->num_domain_grps;
|
||||
info->num_local_groups = info2->num_local_grps;
|
||||
|
||||
/*if these have been ZERO'd out we need to know. uni_str_len will be 0 */
|
||||
if ( info2->uni_comment.uni_str_len == 0 ) {
|
||||
info->comment = talloc_strdup( mem_ctx, "\0" );
|
||||
} else {
|
||||
info->comment =
|
||||
talloc_unistr2_to_ascii( mem_ctx,
|
||||
info2->uni_comment );
|
||||
}
|
||||
|
||||
if ( info2->uni_domain.uni_str_len == 0 ) {
|
||||
info->domain_name = talloc_strdup( mem_ctx, "\0" );
|
||||
} else {
|
||||
info->domain_name =
|
||||
talloc_unistr2_to_ascii( mem_ctx, info2->uni_domain );
|
||||
}
|
||||
|
||||
if ( info2->uni_server.uni_str_len == 0 ) {
|
||||
info->server_name = talloc_strdup( mem_ctx, "\0" );
|
||||
} else {
|
||||
info->server_name =
|
||||
talloc_unistr2_to_ascii( mem_ctx, info2->uni_server );
|
||||
}
|
||||
|
||||
|
||||
cac_InitCacTime( &( info->lockout_duration ), info12->duration );
|
||||
cac_InitCacTime( &( info->lockout_reset ), info12->reset_count );
|
||||
info->num_bad_attempts = info12->bad_attempt_lockout;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
char *cac_unistr_ascii( TALLOC_CTX * mem_ctx, UNISTR src )
|
||||
{
|
||||
char *buf;
|
||||
uint32 len;
|
||||
|
||||
if ( !mem_ctx || !src.buffer )
|
||||
return NULL;
|
||||
|
||||
len = unistrlen( src.buffer ) + 1;
|
||||
|
||||
buf = TALLOC_ZERO_ARRAY( mem_ctx, char, len );
|
||||
if ( !buf )
|
||||
return NULL;
|
||||
|
||||
rpcstr_pull( buf, src.buffer, len, -1, STR_TERMINATE );
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
CacService *cac_MakeServiceArray( TALLOC_CTX * mem_ctx,
|
||||
ENUM_SERVICES_STATUS * svc,
|
||||
uint32 num_services )
|
||||
{
|
||||
int i;
|
||||
CacService *services = NULL;
|
||||
|
||||
if ( !mem_ctx || !svc )
|
||||
return NULL;
|
||||
|
||||
if (num_services) {
|
||||
services = TALLOC_ZERO_ARRAY( mem_ctx, CacService, num_services );
|
||||
if ( !services )
|
||||
return NULL;
|
||||
} else {
|
||||
services = NULL;
|
||||
}
|
||||
|
||||
for ( i = 0; i < num_services; i++ ) {
|
||||
services[i].service_name =
|
||||
cac_unistr_ascii( mem_ctx, svc[i].servicename );
|
||||
services[i].display_name =
|
||||
cac_unistr_ascii( mem_ctx, svc[i].displayname );
|
||||
|
||||
if ( !services[i].service_name || !services[i].display_name )
|
||||
return NULL;
|
||||
|
||||
services[i].status = svc[i].status;
|
||||
}
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
int cac_InitCacServiceConfig( TALLOC_CTX * mem_ctx, SERVICE_CONFIG * src,
|
||||
CacServiceConfig * dest )
|
||||
{
|
||||
if ( !src || !dest )
|
||||
return CAC_FAILURE;
|
||||
|
||||
dest->exe_path =
|
||||
talloc_unistr2_to_ascii( mem_ctx, *src->executablepath );
|
||||
if ( !dest->exe_path )
|
||||
return CAC_FAILURE;
|
||||
|
||||
dest->load_order_group =
|
||||
talloc_unistr2_to_ascii( mem_ctx, *src->loadordergroup );
|
||||
if ( !dest->load_order_group )
|
||||
return CAC_FAILURE;
|
||||
|
||||
dest->dependencies =
|
||||
talloc_unistr2_to_ascii( mem_ctx, *src->dependencies );
|
||||
if ( !dest->dependencies )
|
||||
return CAC_FAILURE;
|
||||
|
||||
dest->start_name =
|
||||
talloc_unistr2_to_ascii( mem_ctx, *src->startname );
|
||||
if ( !dest->start_name )
|
||||
return CAC_FAILURE;
|
||||
|
||||
dest->display_name =
|
||||
talloc_unistr2_to_ascii( mem_ctx, *src->displayname );
|
||||
if ( !dest->display_name )
|
||||
return CAC_FAILURE;
|
||||
|
||||
dest->type = src->service_type;
|
||||
dest->start_type = src->start_type;
|
||||
dest->error_control = src->error_control;
|
||||
dest->tag_id = src->tag_id;
|
||||
|
||||
return CAC_SUCCESS;
|
||||
}
|
@ -98,7 +98,7 @@ static NTSTATUS cli_session_setup_lanman2(struct cli_state *cli,
|
||||
|
||||
/* send a session setup command */
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
set_message(NULL,cli->outbuf,10, 0, True);
|
||||
set_message(cli->outbuf,10, 0, True);
|
||||
SCVAL(cli->outbuf,smb_com,SMBsesssetupX);
|
||||
cli_setup_packet(cli);
|
||||
|
||||
@ -168,7 +168,7 @@ static NTSTATUS cli_session_setup_guest(struct cli_state *cli)
|
||||
uint32 capabilities = cli_session_setup_capabilities(cli);
|
||||
|
||||
memset(cli->outbuf, '\0', smb_size);
|
||||
set_message(NULL,cli->outbuf,13,0,True);
|
||||
set_message(cli->outbuf,13,0,True);
|
||||
SCVAL(cli->outbuf,smb_com,SMBsesssetupX);
|
||||
cli_setup_packet(cli);
|
||||
|
||||
@ -228,7 +228,7 @@ static NTSTATUS cli_session_setup_plaintext(struct cli_state *cli,
|
||||
fstr_sprintf( lanman, "Samba %s", SAMBA_VERSION_STRING);
|
||||
|
||||
memset(cli->outbuf, '\0', smb_size);
|
||||
set_message(NULL,cli->outbuf,13,0,True);
|
||||
set_message(cli->outbuf,13,0,True);
|
||||
SCVAL(cli->outbuf,smb_com,SMBsesssetupX);
|
||||
cli_setup_packet(cli);
|
||||
|
||||
@ -377,7 +377,7 @@ static NTSTATUS cli_session_setup_nt1(struct cli_state *cli, const char *user,
|
||||
/* send a session setup command */
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf,13,0,True);
|
||||
set_message(cli->outbuf,13,0,True);
|
||||
SCVAL(cli->outbuf,smb_com,SMBsesssetupX);
|
||||
cli_setup_packet(cli);
|
||||
|
||||
@ -457,7 +457,7 @@ static BOOL cli_session_setup_blob_send(struct cli_state *cli, DATA_BLOB blob)
|
||||
/* send a session setup command */
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf,12,0,True);
|
||||
set_message(cli->outbuf,12,0,True);
|
||||
SCVAL(cli->outbuf,smb_com,SMBsesssetupX);
|
||||
|
||||
cli_setup_packet(cli);
|
||||
@ -765,7 +765,7 @@ static NTSTATUS cli_session_setup_ntlmssp(struct cli_state *cli, const char *use
|
||||
}
|
||||
}
|
||||
|
||||
/* we have a reference counter on ntlmssp_state, if we are signing
|
||||
/* we have a reference conter on ntlmssp_state, if we are signing
|
||||
then the state will be kept by the signing engine */
|
||||
|
||||
ntlmssp_end(&ntlmssp_state);
|
||||
@ -978,6 +978,7 @@ NTSTATUS cli_session_setup(struct cli_state *cli,
|
||||
}
|
||||
|
||||
return NT_STATUS_OK;
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -987,7 +988,7 @@ NTSTATUS cli_session_setup(struct cli_state *cli,
|
||||
BOOL cli_ulogoff(struct cli_state *cli)
|
||||
{
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
set_message(NULL,cli->outbuf,2,0,True);
|
||||
set_message(cli->outbuf,2,0,True);
|
||||
SCVAL(cli->outbuf,smb_com,SMBulogoffX);
|
||||
cli_setup_packet(cli);
|
||||
SSVAL(cli->outbuf,smb_vwv0,0xFF);
|
||||
@ -1064,7 +1065,7 @@ BOOL cli_send_tconX(struct cli_state *cli,
|
||||
slprintf(fullshare, sizeof(fullshare)-1,
|
||||
"\\\\%s\\%s", cli->desthost, share);
|
||||
|
||||
set_message(NULL,cli->outbuf,4, 0, True);
|
||||
set_message(cli->outbuf,4, 0, True);
|
||||
SCVAL(cli->outbuf,smb_com,SMBtconX);
|
||||
cli_setup_packet(cli);
|
||||
|
||||
@ -1115,7 +1116,7 @@ BOOL cli_send_tconX(struct cli_state *cli,
|
||||
BOOL cli_tdis(struct cli_state *cli)
|
||||
{
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
set_message(NULL,cli->outbuf,0,0,True);
|
||||
set_message(cli->outbuf,0,0,True);
|
||||
SCVAL(cli->outbuf,smb_com,SMBtdis);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
cli_setup_packet(cli);
|
||||
@ -1147,7 +1148,7 @@ void cli_negprot_send(struct cli_state *cli)
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
|
||||
/* setup the protocol strings */
|
||||
set_message(NULL,cli->outbuf,0,0,True);
|
||||
set_message(cli->outbuf,0,0,True);
|
||||
|
||||
p = smb_buf(cli->outbuf);
|
||||
for (numprots=0;
|
||||
@ -1187,7 +1188,7 @@ BOOL cli_negprot(struct cli_state *cli)
|
||||
numprots++)
|
||||
plength += strlen(prots[numprots].name)+2;
|
||||
|
||||
set_message(NULL,cli->outbuf,0,plength,True);
|
||||
set_message(cli->outbuf,0,plength,True);
|
||||
|
||||
p = smb_buf(cli->outbuf);
|
||||
for (numprots=0;
|
||||
@ -1720,7 +1721,7 @@ NTSTATUS cli_raw_tcon(struct cli_state *cli,
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0',smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf, 0, 0, True);
|
||||
set_message(cli->outbuf, 0, 0, True);
|
||||
SCVAL(cli->outbuf,smb_com,SMBtcon);
|
||||
cli_setup_packet(cli);
|
||||
|
||||
|
@ -69,7 +69,7 @@ BOOL cli_send_mailslot(struct messaging_context *msg_ctx,
|
||||
/* Setup the smb part. */
|
||||
ptr -= 4; /* XXX Ugliness because of handling of tcp SMB length. */
|
||||
memcpy(tmp,ptr,4);
|
||||
set_message(NULL,ptr,17,strlen(mailslot) + 1 + len,True);
|
||||
set_message(ptr,17,strlen(mailslot) + 1 + len,True);
|
||||
memcpy(ptr,tmp,4);
|
||||
|
||||
SCVAL(ptr,smb_com,SMBtrans);
|
||||
|
@ -48,18 +48,15 @@ int cli_set_port(struct cli_state *cli, int port)
|
||||
*MUST* be of size BUFFER_SIZE+SAFETY_MARGIN.
|
||||
The timeout is in milliseconds
|
||||
|
||||
This is exactly the same as receive_smb except that it can be set to never return
|
||||
This is exactly the same as receive_smb except that it never returns
|
||||
a session keepalive packet (just as receive_smb used to do).
|
||||
receive_smb was changed to return keepalives as the oplock processing means this call
|
||||
should never go into a blocking read.
|
||||
****************************************************************************/
|
||||
|
||||
static ssize_t client_receive_smb(struct cli_state *cli, BOOL eat_keepalives, size_t maxlen)
|
||||
static ssize_t client_receive_smb(int fd,char *buffer, unsigned int timeout, size_t maxlen)
|
||||
{
|
||||
ssize_t len;
|
||||
int fd = cli->fd;
|
||||
char *buffer = cli->inbuf;
|
||||
unsigned int timeout = cli->timeout;
|
||||
|
||||
for(;;) {
|
||||
len = receive_smb_raw(fd, buffer, timeout, maxlen);
|
||||
@ -71,22 +68,8 @@ static ssize_t client_receive_smb(struct cli_state *cli, BOOL eat_keepalives, si
|
||||
}
|
||||
|
||||
/* Ignore session keepalive packets. */
|
||||
if (eat_keepalives && (CVAL(buffer,0) == SMBkeepalive)) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (cli_encryption_on(cli)) {
|
||||
NTSTATUS status = cli_decrypt_message(cli);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DEBUG(0, ("SMB decryption failed on incoming packet! Error %s\n",
|
||||
nt_errstr(status)));
|
||||
cli->smb_rw_error = READ_BAD_DECRYPT;
|
||||
close(cli->fd);
|
||||
cli->fd = -1;
|
||||
return -1;
|
||||
}
|
||||
if(CVAL(buffer,0) != SMBkeepalive)
|
||||
break;
|
||||
}
|
||||
show_msg(buffer);
|
||||
return len;
|
||||
@ -96,7 +79,7 @@ static ssize_t client_receive_smb(struct cli_state *cli, BOOL eat_keepalives, si
|
||||
Recv an smb.
|
||||
****************************************************************************/
|
||||
|
||||
BOOL cli_receive_smb_internal(struct cli_state *cli, BOOL eat_keepalives)
|
||||
BOOL cli_receive_smb(struct cli_state *cli)
|
||||
{
|
||||
ssize_t len;
|
||||
|
||||
@ -105,12 +88,7 @@ BOOL cli_receive_smb_internal(struct cli_state *cli, BOOL eat_keepalives)
|
||||
return False;
|
||||
|
||||
again:
|
||||
len = client_receive_smb(cli, eat_keepalives, 0);
|
||||
|
||||
if (len >= 0 && !eat_keepalives && (CVAL(cli->inbuf,0) == SMBkeepalive)) {
|
||||
/* Give back the keepalive. */
|
||||
return True;
|
||||
}
|
||||
len = client_receive_smb(cli->fd,cli->inbuf,cli->timeout, 0);
|
||||
|
||||
if (len > 0) {
|
||||
/* it might be an oplock break request */
|
||||
@ -166,29 +144,10 @@ BOOL cli_receive_smb_internal(struct cli_state *cli, BOOL eat_keepalives)
|
||||
close(cli->fd);
|
||||
cli->fd = -1;
|
||||
return False;
|
||||
}
|
||||
|
||||
};
|
||||
return True;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Recv an smb - eat keepalives.
|
||||
****************************************************************************/
|
||||
|
||||
BOOL cli_receive_smb(struct cli_state *cli)
|
||||
{
|
||||
return cli_receive_smb_internal(cli, True);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Recv an smb - return keepalives.
|
||||
****************************************************************************/
|
||||
|
||||
BOOL cli_receive_smb_return_keepalive(struct cli_state *cli)
|
||||
{
|
||||
return cli_receive_smb_internal(cli, False);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
Read the data portion of a readX smb.
|
||||
The timeout is in milliseconds
|
||||
@ -205,7 +164,6 @@ ssize_t cli_receive_smb_data(struct cli_state *cli, char *buffer, size_t len)
|
||||
|
||||
/****************************************************************************
|
||||
Read a smb readX header.
|
||||
We can only use this if encryption and signing are off.
|
||||
****************************************************************************/
|
||||
|
||||
BOOL cli_receive_smb_readX_header(struct cli_state *cli)
|
||||
@ -218,7 +176,7 @@ BOOL cli_receive_smb_readX_header(struct cli_state *cli)
|
||||
again:
|
||||
|
||||
/* Read up to the size of a readX header reply. */
|
||||
len = client_receive_smb(cli, True, (smb_size - 4) + 24);
|
||||
len = client_receive_smb(cli->fd, cli->inbuf, cli->timeout, (smb_size - 4) + 24);
|
||||
|
||||
if (len > 0) {
|
||||
/* it might be an oplock break request */
|
||||
@ -296,7 +254,7 @@ static ssize_t write_socket(int fd, const char *buf, size_t len)
|
||||
|
||||
DEBUG(6,("write_socket(%d,%d)\n",fd,(int)len));
|
||||
ret = write_data(fd,buf,len);
|
||||
|
||||
|
||||
DEBUG(6,("write_socket(%d,%d) wrote %d\n",fd,(int)len,(int)ret));
|
||||
if(ret <= 0)
|
||||
DEBUG(0,("write_socket: Error writing %d bytes to socket %d: ERRNO = %s\n",
|
||||
@ -314,36 +272,18 @@ BOOL cli_send_smb(struct cli_state *cli)
|
||||
size_t len;
|
||||
size_t nwritten=0;
|
||||
ssize_t ret;
|
||||
char *buf_out = cli->outbuf;
|
||||
BOOL enc_on = cli_encryption_on(cli);
|
||||
|
||||
/* fd == -1 causes segfaults -- Tom (tom@ninja.nl) */
|
||||
if (cli->fd == -1) {
|
||||
if (cli->fd == -1)
|
||||
return False;
|
||||
}
|
||||
|
||||
cli_calculate_sign_mac(cli);
|
||||
|
||||
if (enc_on) {
|
||||
NTSTATUS status = cli_encrypt_message(cli, &buf_out);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
close(cli->fd);
|
||||
cli->fd = -1;
|
||||
cli->smb_rw_error = WRITE_ERROR;
|
||||
DEBUG(0,("Error in encrypting client message. Error %s\n",
|
||||
nt_errstr(status) ));
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
len = smb_len(buf_out) + 4;
|
||||
len = smb_len(cli->outbuf) + 4;
|
||||
|
||||
while (nwritten < len) {
|
||||
ret = write_socket(cli->fd,buf_out+nwritten,len - nwritten);
|
||||
ret = write_socket(cli->fd,cli->outbuf+nwritten,len - nwritten);
|
||||
if (ret <= 0) {
|
||||
if (enc_on) {
|
||||
cli_free_enc_buffer(cli, buf_out);
|
||||
}
|
||||
close(cli->fd);
|
||||
cli->fd = -1;
|
||||
cli->smb_rw_error = WRITE_ERROR;
|
||||
@ -353,14 +293,10 @@ BOOL cli_send_smb(struct cli_state *cli)
|
||||
}
|
||||
nwritten += ret;
|
||||
}
|
||||
|
||||
cli_free_enc_buffer(cli, buf_out);
|
||||
|
||||
/* Increment the mid so we can tell between responses. */
|
||||
cli->mid++;
|
||||
if (!cli->mid) {
|
||||
if (!cli->mid)
|
||||
cli->mid++;
|
||||
}
|
||||
return True;
|
||||
}
|
||||
|
||||
@ -401,7 +337,7 @@ void cli_setup_packet(struct cli_state *cli)
|
||||
|
||||
void cli_setup_bcc(struct cli_state *cli, void *p)
|
||||
{
|
||||
set_message_bcc(NULL,cli->outbuf, PTR_DIFF(p, smb_buf(cli->outbuf)));
|
||||
set_message_bcc(cli->outbuf, PTR_DIFF(p, smb_buf(cli->outbuf)));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -607,8 +543,6 @@ void cli_shutdown(struct cli_state *cli)
|
||||
SAFE_FREE(cli->inbuf);
|
||||
|
||||
cli_free_signing_context(cli);
|
||||
cli_free_encryption_context(cli);
|
||||
|
||||
data_blob_free(&cli->secblob);
|
||||
data_blob_free(&cli->user_session_key);
|
||||
|
||||
@ -689,7 +623,7 @@ BOOL cli_echo(struct cli_state *cli, uint16 num_echos,
|
||||
SMB_ASSERT(length < 1024);
|
||||
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
set_message(NULL,cli->outbuf,1,length,True);
|
||||
set_message(cli->outbuf,1,length,True);
|
||||
SCVAL(cli->outbuf,smb_com,SMBecho);
|
||||
SSVAL(cli->outbuf,smb_tid,65535);
|
||||
SSVAL(cli->outbuf,smb_vwv0,num_echos);
|
||||
|
@ -83,7 +83,6 @@ static NTSTATUS cli_smb_rw_error_to_ntstatus(struct cli_state *cli)
|
||||
case WRITE_ERROR:
|
||||
return NT_STATUS_UNEXPECTED_NETWORK_ERROR;
|
||||
case READ_BAD_SIG:
|
||||
case READ_BAD_DECRYPT:
|
||||
return NT_STATUS_INVALID_PARAMETER;
|
||||
default:
|
||||
break;
|
||||
@ -133,10 +132,6 @@ const char *cli_errstr(struct cli_state *cli)
|
||||
slprintf(cli_error_message, sizeof(cli_error_message) - 1,
|
||||
"Server packet had invalid SMB signature!");
|
||||
break;
|
||||
case READ_BAD_DECRYPT:
|
||||
slprintf(cli_error_message, sizeof(cli_error_message) - 1,
|
||||
"Server packet could not be decrypted !");
|
||||
break;
|
||||
default:
|
||||
slprintf(cli_error_message, sizeof(cli_error_message) - 1,
|
||||
"Unknown error code %d\n", cli->smb_rw_error );
|
||||
|
@ -389,7 +389,7 @@ BOOL cli_rename(struct cli_state *cli, const char *fname_src, const char *fname_
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0',smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf,1, 0, True);
|
||||
set_message(cli->outbuf,1, 0, True);
|
||||
|
||||
SCVAL(cli->outbuf,smb_com,SMBmv);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
@ -426,7 +426,7 @@ BOOL cli_ntrename(struct cli_state *cli, const char *fname_src, const char *fnam
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0',smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf, 4, 0, True);
|
||||
set_message(cli->outbuf, 4, 0, True);
|
||||
|
||||
SCVAL(cli->outbuf,smb_com,SMBntrename);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
@ -464,7 +464,7 @@ BOOL cli_nt_hardlink(struct cli_state *cli, const char *fname_src, const char *f
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0',smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf, 4, 0, True);
|
||||
set_message(cli->outbuf, 4, 0, True);
|
||||
|
||||
SCVAL(cli->outbuf,smb_com,SMBntrename);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
@ -502,7 +502,7 @@ BOOL cli_unlink_full(struct cli_state *cli, const char *fname, uint16 attrs)
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0',smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf,1, 0,True);
|
||||
set_message(cli->outbuf,1, 0,True);
|
||||
|
||||
SCVAL(cli->outbuf,smb_com,SMBunlink);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
@ -547,7 +547,7 @@ BOOL cli_mkdir(struct cli_state *cli, const char *dname)
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0',smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf,0, 0,True);
|
||||
set_message(cli->outbuf,0, 0,True);
|
||||
|
||||
SCVAL(cli->outbuf,smb_com,SMBmkdir);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
@ -582,7 +582,7 @@ BOOL cli_rmdir(struct cli_state *cli, const char *dname)
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0',smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf,0, 0, True);
|
||||
set_message(cli->outbuf,0, 0, True);
|
||||
|
||||
SCVAL(cli->outbuf,smb_com,SMBrmdir);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
@ -664,7 +664,7 @@ int cli_nt_create_full(struct cli_state *cli, const char *fname,
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0',smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf,24,0,True);
|
||||
set_message(cli->outbuf,24,0,True);
|
||||
|
||||
SCVAL(cli->outbuf,smb_com,SMBntcreateX);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
@ -758,7 +758,7 @@ int cli_open(struct cli_state *cli, const char *fname, int flags, int share_mode
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0',smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf,15,0,True);
|
||||
set_message(cli->outbuf,15,0,True);
|
||||
|
||||
SCVAL(cli->outbuf,smb_com,SMBopenX);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
@ -805,7 +805,7 @@ BOOL cli_close(struct cli_state *cli, int fnum)
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0',smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf,3,0,True);
|
||||
set_message(cli->outbuf,3,0,True);
|
||||
|
||||
SCVAL(cli->outbuf,smb_com,SMBclose);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
@ -837,7 +837,7 @@ NTSTATUS cli_locktype(struct cli_state *cli, int fnum,
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0', smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf,8,0,True);
|
||||
set_message(cli->outbuf,8,0,True);
|
||||
|
||||
SCVAL(cli->outbuf,smb_com,SMBlockingX);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
@ -889,7 +889,7 @@ BOOL cli_lock(struct cli_state *cli, int fnum,
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0', smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf,8,0,True);
|
||||
set_message(cli->outbuf,8,0,True);
|
||||
|
||||
SCVAL(cli->outbuf,smb_com,SMBlockingX);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
@ -942,7 +942,7 @@ BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len)
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0',smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf,8,0,True);
|
||||
set_message(cli->outbuf,8,0,True);
|
||||
|
||||
SCVAL(cli->outbuf,smb_com,SMBlockingX);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
@ -994,7 +994,7 @@ BOOL cli_lock64(struct cli_state *cli, int fnum,
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0', smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf,8,0,True);
|
||||
set_message(cli->outbuf,8,0,True);
|
||||
|
||||
SCVAL(cli->outbuf,smb_com,SMBlockingX);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
@ -1049,7 +1049,7 @@ BOOL cli_unlock64(struct cli_state *cli, int fnum, SMB_BIG_UINT offset, SMB_BIG_
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0',smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf,8,0,True);
|
||||
set_message(cli->outbuf,8,0,True);
|
||||
|
||||
SCVAL(cli->outbuf,smb_com,SMBlockingX);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
@ -1196,7 +1196,7 @@ BOOL cli_getattrE(struct cli_state *cli, int fd,
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0',smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf,1,0,True);
|
||||
set_message(cli->outbuf,1,0,True);
|
||||
|
||||
SCVAL(cli->outbuf,smb_com,SMBgetattrE);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
@ -1248,7 +1248,7 @@ BOOL cli_getatr(struct cli_state *cli, const char *fname,
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0',smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf,0,0,True);
|
||||
set_message(cli->outbuf,0,0,True);
|
||||
|
||||
SCVAL(cli->outbuf,smb_com,SMBgetatr);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
@ -1300,7 +1300,7 @@ BOOL cli_setattrE(struct cli_state *cli, int fd,
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0',smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf,7,0,True);
|
||||
set_message(cli->outbuf,7,0,True);
|
||||
|
||||
SCVAL(cli->outbuf,smb_com,SMBsetattrE);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
@ -1339,7 +1339,7 @@ BOOL cli_setatr(struct cli_state *cli, const char *fname, uint16 attr, time_t t)
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0',smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf,8,0,True);
|
||||
set_message(cli->outbuf,8,0,True);
|
||||
|
||||
SCVAL(cli->outbuf,smb_com,SMBsetatr);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
@ -1381,7 +1381,7 @@ BOOL cli_chkpath(struct cli_state *cli, const char *path)
|
||||
*path2 = '\\';
|
||||
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
set_message(NULL,cli->outbuf,0,0,True);
|
||||
set_message(cli->outbuf,0,0,True);
|
||||
SCVAL(cli->outbuf,smb_com,SMBcheckpath);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
cli_setup_packet(cli);
|
||||
@ -1408,7 +1408,7 @@ BOOL cli_chkpath(struct cli_state *cli, const char *path)
|
||||
BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail)
|
||||
{
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
set_message(NULL,cli->outbuf,0,0,True);
|
||||
set_message(cli->outbuf,0,0,True);
|
||||
SCVAL(cli->outbuf,smb_com,SMBdskattr);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
cli_setup_packet(cli);
|
||||
@ -1437,7 +1437,7 @@ int cli_ctemp(struct cli_state *cli, const char *path, char **tmp_path)
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0',smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf,3,0,True);
|
||||
set_message(cli->outbuf,3,0,True);
|
||||
|
||||
SCVAL(cli->outbuf,smb_com,SMBctemp);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
@ -1487,7 +1487,7 @@ NTSTATUS cli_raw_ioctl(struct cli_state *cli, int fnum, uint32 code, DATA_BLOB *
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0',smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf, 3, 0, True);
|
||||
set_message(cli->outbuf, 3, 0, True);
|
||||
SCVAL(cli->outbuf,smb_com,SMBioctl);
|
||||
cli_setup_packet(cli);
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
Unix SMB/CIFS implementation.
|
||||
FS info functions
|
||||
Copyright (C) Stefan (metze) Metzmacher 2003
|
||||
Copyright (C) Jeremy Allison 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
|
||||
@ -302,326 +301,3 @@ cleanup:
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
Send/receive the request encryption blob.
|
||||
******************************************************************************/
|
||||
|
||||
static NTSTATUS enc_blob_send_receive(struct cli_state *cli, DATA_BLOB *in, DATA_BLOB *out, DATA_BLOB *param_out)
|
||||
{
|
||||
uint16 setup;
|
||||
char param[4];
|
||||
char *rparam=NULL, *rdata=NULL;
|
||||
unsigned int rparam_count=0, rdata_count=0;
|
||||
NTSTATUS status = NT_STATUS_OK;
|
||||
|
||||
setup = TRANSACT2_SETFSINFO;
|
||||
|
||||
SSVAL(param,0,0);
|
||||
SSVAL(param,2,SMB_REQUEST_TRANSPORT_ENCRYPTION);
|
||||
|
||||
if (!cli_send_trans(cli, SMBtrans2,
|
||||
NULL,
|
||||
0, 0,
|
||||
&setup, 1, 0,
|
||||
param, 4, 0,
|
||||
(char *)in->data, in->length, CLI_BUFFER_SIZE)) {
|
||||
status = cli_nt_error(cli);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!cli_receive_trans(cli, SMBtrans2,
|
||||
&rparam, &rparam_count,
|
||||
&rdata, &rdata_count)) {
|
||||
status = cli_nt_error(cli);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (cli_is_error(cli)) {
|
||||
status = cli_nt_error(cli);
|
||||
if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
*out = data_blob(rdata, rdata_count);
|
||||
*param_out = data_blob(rparam, rparam_count);
|
||||
|
||||
out:
|
||||
|
||||
SAFE_FREE(rparam);
|
||||
SAFE_FREE(rdata);
|
||||
return status;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
Make a client state struct.
|
||||
******************************************************************************/
|
||||
|
||||
static struct smb_trans_enc_state *make_cli_enc_state(enum smb_trans_enc_type smb_enc_type)
|
||||
{
|
||||
struct smb_trans_enc_state *es = NULL;
|
||||
es = SMB_MALLOC_P(struct smb_trans_enc_state);
|
||||
if (!es) {
|
||||
return NULL;
|
||||
}
|
||||
ZERO_STRUCTP(es);
|
||||
es->smb_enc_type = smb_enc_type;
|
||||
|
||||
if (smb_enc_type == SMB_TRANS_ENC_GSS) {
|
||||
#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
|
||||
es->s.gss_state = SMB_MALLOC_P(struct smb_tran_enc_state_gss);
|
||||
if (!es->s.gss_state) {
|
||||
SAFE_FREE(es);
|
||||
return NULL;
|
||||
}
|
||||
ZERO_STRUCTP(es->s.gss_state);
|
||||
#else
|
||||
DEBUG(0,("make_cli_enc_state: no krb5 compiled.\n"));
|
||||
SAFE_FREE(es);
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
return es;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
Start a raw ntlmssp encryption.
|
||||
******************************************************************************/
|
||||
|
||||
NTSTATUS cli_raw_ntlm_smb_encryption_start(struct cli_state *cli,
|
||||
const char *user,
|
||||
const char *pass,
|
||||
const char *domain)
|
||||
{
|
||||
DATA_BLOB blob_in = data_blob_null;
|
||||
DATA_BLOB blob_out = data_blob_null;
|
||||
DATA_BLOB param_out = data_blob_null;
|
||||
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
|
||||
struct smb_trans_enc_state *es = make_cli_enc_state(SMB_TRANS_ENC_NTLM);
|
||||
|
||||
if (!es) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
status = ntlmssp_client_start(&es->s.ntlmssp_state);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ntlmssp_want_feature(es->s.ntlmssp_state, NTLMSSP_FEATURE_SESSION_KEY);
|
||||
es->s.ntlmssp_state->neg_flags |= (NTLMSSP_NEGOTIATE_SIGN|NTLMSSP_NEGOTIATE_SEAL);
|
||||
|
||||
if (!NT_STATUS_IS_OK(status = ntlmssp_set_username(es->s.ntlmssp_state, user))) {
|
||||
goto fail;
|
||||
}
|
||||
if (!NT_STATUS_IS_OK(status = ntlmssp_set_domain(es->s.ntlmssp_state, domain))) {
|
||||
goto fail;
|
||||
}
|
||||
if (!NT_STATUS_IS_OK(status = ntlmssp_set_password(es->s.ntlmssp_state, pass))) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
do {
|
||||
status = ntlmssp_update(es->s.ntlmssp_state, blob_in, &blob_out);
|
||||
data_blob_free(&blob_in);
|
||||
data_blob_free(¶m_out);
|
||||
if (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED) || NT_STATUS_IS_OK(status)) {
|
||||
status = enc_blob_send_receive(cli, &blob_out, &blob_in, ¶m_out);
|
||||
}
|
||||
if (param_out.length == 2) {
|
||||
es->enc_ctx_num = SVAL(param_out.data, 0);
|
||||
}
|
||||
data_blob_free(&blob_out);
|
||||
} while (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED));
|
||||
|
||||
data_blob_free(&blob_in);
|
||||
|
||||
if (NT_STATUS_IS_OK(status)) {
|
||||
/* Replace the old state, if any. */
|
||||
if (cli->trans_enc_state) {
|
||||
common_free_encryption_state(&cli->trans_enc_state);
|
||||
}
|
||||
cli->trans_enc_state = es;
|
||||
cli->trans_enc_state->enc_on = True;
|
||||
es = NULL;
|
||||
}
|
||||
|
||||
fail:
|
||||
|
||||
common_free_encryption_state(&es);
|
||||
return status;
|
||||
}
|
||||
|
||||
#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
|
||||
|
||||
#ifndef SMB_GSS_REQUIRED_FLAGS
|
||||
#define SMB_GSS_REQUIRED_FLAGS (GSS_C_CONF_FLAG|GSS_C_INTEG_FLAG|GSS_C_MUTUAL_FLAG|GSS_C_REPLAY_FLAG|GSS_C_SEQUENCE_FLAG)
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
Get client gss blob to send to a server.
|
||||
******************************************************************************/
|
||||
|
||||
static NTSTATUS make_cli_gss_blob(struct smb_trans_enc_state *es,
|
||||
const char *service,
|
||||
const char *host,
|
||||
NTSTATUS status_in,
|
||||
DATA_BLOB spnego_blob_in,
|
||||
DATA_BLOB *p_blob_out)
|
||||
{
|
||||
const char *krb_mechs[] = {OID_KERBEROS5, NULL};
|
||||
OM_uint32 ret;
|
||||
OM_uint32 min;
|
||||
gss_name_t srv_name;
|
||||
gss_buffer_desc input_name;
|
||||
gss_buffer_desc *p_tok_in;
|
||||
gss_buffer_desc tok_out, tok_in;
|
||||
DATA_BLOB blob_out = data_blob_null;
|
||||
DATA_BLOB blob_in = data_blob_null;
|
||||
char *host_princ_s = NULL;
|
||||
OM_uint32 ret_flags = 0;
|
||||
NTSTATUS status = NT_STATUS_OK;
|
||||
|
||||
gss_OID_desc nt_hostbased_service =
|
||||
{10, CONST_DISCARD(char *,"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04")};
|
||||
|
||||
memset(&tok_out, '\0', sizeof(tok_out));
|
||||
|
||||
/* Get a ticket for the service@host */
|
||||
asprintf(&host_princ_s, "%s@%s", service, host);
|
||||
if (host_princ_s == NULL) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
input_name.value = host_princ_s;
|
||||
input_name.length = strlen(host_princ_s) + 1;
|
||||
|
||||
ret = gss_import_name(&min,
|
||||
&input_name,
|
||||
&nt_hostbased_service,
|
||||
&srv_name);
|
||||
|
||||
if (ret != GSS_S_COMPLETE) {
|
||||
SAFE_FREE(host_princ_s);
|
||||
return map_nt_error_from_gss(ret, min);
|
||||
}
|
||||
|
||||
if (spnego_blob_in.length == 0) {
|
||||
p_tok_in = GSS_C_NO_BUFFER;
|
||||
} else {
|
||||
/* Remove the SPNEGO wrapper */
|
||||
if (!spnego_parse_auth_response(spnego_blob_in, status_in, OID_KERBEROS5, &blob_in)) {
|
||||
status = NT_STATUS_UNSUCCESSFUL;
|
||||
goto fail;
|
||||
}
|
||||
tok_in.value = blob_in.data;
|
||||
tok_in.length = blob_in.length;
|
||||
p_tok_in = &tok_in;
|
||||
}
|
||||
|
||||
ret = gss_init_sec_context(&min,
|
||||
GSS_C_NO_CREDENTIAL, /* Use our default cred. */
|
||||
&es->s.gss_state->gss_ctx,
|
||||
srv_name,
|
||||
GSS_C_NO_OID, /* default OID. */
|
||||
GSS_C_MUTUAL_FLAG | GSS_C_REPLAY_FLAG | GSS_C_SEQUENCE_FLAG,
|
||||
GSS_C_INDEFINITE, /* requested ticket lifetime. */
|
||||
NULL, /* no channel bindings */
|
||||
p_tok_in,
|
||||
NULL, /* ignore mech type */
|
||||
&tok_out,
|
||||
&ret_flags,
|
||||
NULL); /* ignore time_rec */
|
||||
|
||||
status = map_nt_error_from_gss(ret, min);
|
||||
if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status,NT_STATUS_MORE_PROCESSING_REQUIRED)) {
|
||||
ADS_STATUS adss = ADS_ERROR_GSS(ret, min);
|
||||
DEBUG(10,("make_cli_gss_blob: gss_init_sec_context failed with %s\n",
|
||||
ads_errstr(adss)));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((ret_flags & SMB_GSS_REQUIRED_FLAGS) != SMB_GSS_REQUIRED_FLAGS) {
|
||||
status = NT_STATUS_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
blob_out = data_blob(tok_out.value, tok_out.length);
|
||||
|
||||
/* Wrap in an SPNEGO wrapper */
|
||||
*p_blob_out = gen_negTokenTarg(krb_mechs, blob_out);
|
||||
|
||||
fail:
|
||||
|
||||
data_blob_free(&blob_out);
|
||||
data_blob_free(&blob_in);
|
||||
SAFE_FREE(host_princ_s);
|
||||
gss_release_name(&min, &srv_name);
|
||||
if (tok_out.value) {
|
||||
gss_release_buffer(&min, &tok_out);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
Start a SPNEGO gssapi encryption context.
|
||||
******************************************************************************/
|
||||
|
||||
NTSTATUS cli_gss_smb_encryption_start(struct cli_state *cli)
|
||||
{
|
||||
DATA_BLOB blob_recv = data_blob_null;
|
||||
DATA_BLOB blob_send = data_blob_null;
|
||||
DATA_BLOB param_out = data_blob_null;
|
||||
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
|
||||
fstring fqdn;
|
||||
const char *servicename;
|
||||
struct smb_trans_enc_state *es = make_cli_enc_state(SMB_TRANS_ENC_GSS);
|
||||
|
||||
if (!es) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
name_to_fqdn(fqdn, cli->desthost);
|
||||
strlower_m(fqdn);
|
||||
|
||||
servicename = "cifs";
|
||||
status = make_cli_gss_blob(es, servicename, fqdn, NT_STATUS_OK, blob_recv, &blob_send);
|
||||
if (!NT_STATUS_EQUAL(status,NT_STATUS_MORE_PROCESSING_REQUIRED)) {
|
||||
servicename = "host";
|
||||
status = make_cli_gss_blob(es, servicename, fqdn, NT_STATUS_OK, blob_recv, &blob_send);
|
||||
if (!NT_STATUS_EQUAL(status,NT_STATUS_MORE_PROCESSING_REQUIRED)) {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
data_blob_free(&blob_recv);
|
||||
status = enc_blob_send_receive(cli, &blob_send, &blob_recv, ¶m_out);
|
||||
if (param_out.length == 2) {
|
||||
es->enc_ctx_num = SVAL(param_out.data, 0);
|
||||
}
|
||||
data_blob_free(&blob_send);
|
||||
status = make_cli_gss_blob(es, servicename, fqdn, status, blob_recv, &blob_send);
|
||||
} while (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED));
|
||||
data_blob_free(&blob_recv);
|
||||
|
||||
if (NT_STATUS_IS_OK(status)) {
|
||||
/* Replace the old state, if any. */
|
||||
if (cli->trans_enc_state) {
|
||||
common_free_encryption_state(&cli->trans_enc_state);
|
||||
}
|
||||
cli->trans_enc_state = es;
|
||||
cli->trans_enc_state->enc_on = True;
|
||||
es = NULL;
|
||||
}
|
||||
|
||||
fail:
|
||||
|
||||
common_free_encryption_state(&es);
|
||||
return status;
|
||||
}
|
||||
#else
|
||||
NTSTATUS cli_gss_smb_encryption_start(struct cli_state *cli)
|
||||
{
|
||||
return NT_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
#endif
|
||||
|
@ -417,7 +417,7 @@ int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0',smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf,2,0,True);
|
||||
set_message(cli->outbuf,2,0,True);
|
||||
|
||||
SCVAL(cli->outbuf,smb_com,SMBsearch);
|
||||
|
||||
@ -474,7 +474,7 @@ int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0',smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf,2,0,True);
|
||||
set_message(cli->outbuf,2,0,True);
|
||||
SCVAL(cli->outbuf,smb_com,SMBfclose);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
cli_setup_packet(cli);
|
||||
|
@ -29,7 +29,7 @@ int cli_message_start_build(struct cli_state *cli, char *host, char *username)
|
||||
|
||||
/* construct a SMBsendstrt command */
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
set_message(NULL,cli->outbuf,0,0,True);
|
||||
set_message(cli->outbuf,0,0,True);
|
||||
SCVAL(cli->outbuf,smb_com,SMBsendstrt);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
cli_setup_packet(cli);
|
||||
@ -74,7 +74,7 @@ int cli_message_text_build(struct cli_state *cli, char *msg, int len, int grp)
|
||||
char *p;
|
||||
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
set_message(NULL,cli->outbuf,1,0,True);
|
||||
set_message(cli->outbuf,1,0,True);
|
||||
SCVAL(cli->outbuf,smb_com,SMBsendtxt);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
cli_setup_packet(cli);
|
||||
@ -124,7 +124,7 @@ int cli_message_end_build(struct cli_state *cli, int grp)
|
||||
char *p;
|
||||
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
set_message(NULL,cli->outbuf,1,0,True);
|
||||
set_message(cli->outbuf,1,0,True);
|
||||
SCVAL(cli->outbuf,smb_com,SMBsendend);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
|
||||
|
@ -31,7 +31,7 @@ BOOL cli_oplock_ack(struct cli_state *cli, int fnum, unsigned char level)
|
||||
cli->outbuf = buf;
|
||||
|
||||
memset(buf,'\0',smb_size);
|
||||
set_message(NULL,buf,8,0,True);
|
||||
set_message(buf,8,0,True);
|
||||
|
||||
SCVAL(buf,smb_com,SMBlockingX);
|
||||
SSVAL(buf,smb_tid, cli->cnum);
|
||||
|
@ -193,7 +193,7 @@ int cli_spl_open(struct cli_state *cli, const char *fname, int flags, int share_
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0',smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf,15,0,True);
|
||||
set_message(cli->outbuf,15,0,True);
|
||||
|
||||
SCVAL(cli->outbuf,smb_com,SMBsplopen);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
@ -240,7 +240,7 @@ BOOL cli_spl_close(struct cli_state *cli, int fnum)
|
||||
memset(cli->outbuf,'\0',smb_size);
|
||||
memset(cli->inbuf,'\0',smb_size);
|
||||
|
||||
set_message(NULL,cli->outbuf,3,0,True);
|
||||
set_message(cli->outbuf,3,0,True);
|
||||
|
||||
SCVAL(cli->outbuf,smb_com,SMBsplclose);
|
||||
SSVAL(cli->outbuf,smb_tid,cli->cnum);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user