+++ /dev/null
-*.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
- 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
+ ==============================
+++ /dev/null
- 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
+++ /dev/null
-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
+++ /dev/null
-/*
- * 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;
-}
+++ /dev/null
-/*
- * 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_*/
+++ /dev/null
-/*
- * 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);
-}
+++ /dev/null
-/*
- * 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);
-}
+++ /dev/null
-/*
- * 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);
-}
+++ /dev/null
-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
+++ /dev/null
-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
+++ /dev/null
-/* 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;
-}
+++ /dev/null
-/*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;
-}
+++ /dev/null
-/*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;
-}
+++ /dev/null
-/* 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;
-}
-
+++ /dev/null
-/*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;
-
-}
-
+++ /dev/null
-/* 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;
-}
+++ /dev/null
-/*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;
-}
+++ /dev/null
-/*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;
-}
-
-
+++ /dev/null
-/*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;
-
-}
+++ /dev/null
-/*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;
-
-}
+++ /dev/null
-/*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;
-
-}
+++ /dev/null
-/*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;
-
-}
+++ /dev/null
-/*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;
-
-}
+++ /dev/null
-/*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;
-
-}
+++ /dev/null
-/*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;
-}
-
-
+++ /dev/null
-/*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;
-
-}
+++ /dev/null
-/*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;
-}
-
-
+++ /dev/null
-/*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;
-}
+++ /dev/null
-/*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*/
+++ /dev/null
-/*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;
-}
-
+++ /dev/null
-/*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;
-}
-
+++ /dev/null
-/*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;
-}
-
+++ /dev/null
-/*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;
-
-}
-
+++ /dev/null
-/*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;
-}
-
+++ /dev/null
-/*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;
-
-}
-
+++ /dev/null
-/*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;
-}
-
+++ /dev/null
-/*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;
-}
+++ /dev/null
-/*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;
-}
-
+++ /dev/null
-/*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);
-}
+++ /dev/null
-#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*/
+++ /dev/null
-#!/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));
- }
-}
-
+++ /dev/null
-#!/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();
-
+++ /dev/null
-#!/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 )
--- /dev/null
+-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
+++ /dev/null
-# 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
-}
# 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 =
datarootdir=@datarootdir@
selftest_prefix=@selftest_prefix@
-samba4srcdir=@samba4srcdir@
+smbtorture4_path=@smbtorture4_path@
LIBS=@LIBS@
CC=@CC@
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@
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@
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
# 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@
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) \
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)
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
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 \
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) \
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) \
$(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
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
$(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) \
$(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)
WINBINDD_OBJ1 = \
winbindd/winbindd.o \
- winbindd/winbindd_sockinit.o \
winbindd/winbindd_user.o \
winbindd/winbindd_group.o \
winbindd/winbindd_util.o \
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 = \
$(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) \
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
$(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
@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 $@
@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)
"$(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)
# 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) \
|| 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}"
+++ /dev/null
-- 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
########################################################
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> #
****************************************************************************/
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);
*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"));
}
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
****************************************************************************/
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)
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 {
+++ /dev/null
-#!/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
/****************************************************************************
****************************************************************************/
-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;
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) {
return False;
}
+ init_enum_hnd(&enum_hnd, 0);
+
pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SRVSVC, &status);
if (pipe_hnd == NULL) {
return False;
}
- ZERO_STRUCT(ctr1);
- level = 1;
- ctr.ctr1 = &ctr1;
-
- status = rpccli_srvsvc_NetShareEnum(pipe_hnd, mem_ctx, "", &level,
- &ctr, 0xffffffff, &numentries,
- &enum_hnd);
+ werr = rpccli_srvsvc_net_share_enum(pipe_hnd, mem_ctx, 1, &ctr,
+ 0xffffffff, &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);
{"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}},
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;
} 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;
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)
#################################################
# 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)],
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
])
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])])
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"
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"
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*)
#include <sys/utsname.h>
#include <string.h>
#include <stdlib.h>
-int main() {
+main() {
#if _LFS64_LARGEFILE == 1
struct utsname uts;
char *release;
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 */
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])
*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"
;;
#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"
# 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])
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])
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)
#
#
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
#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])
#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])
#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])
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"
# 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"
*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
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])
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])
#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])
#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])
#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])
#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])
#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])
#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])
#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])
#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])
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])
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
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
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])
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])
#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;
}
#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)])
#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)])
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,
#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,
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"])])
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
#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)])
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)])
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)
samba_cv_HAVE_WRFILE_KEYTAB,[
AC_TRY_RUN([
#include<krb5.h>
- int main()
+ main()
{
krb5_context context;
krb5_keytab keytab;
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])
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=
main ()
{
struct statvfs64 fsd;
- return statvfs64 (".", &fsd);
+ exit (statvfs64 (".", &fsd));
}],
fu_cv_sys_stat_statvfs64=yes,
fu_cv_sys_stat_statvfs64=no,
{
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,
{
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,
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,
{
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,
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,
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>],
[\
AC_CACHE_CHECK([for Linux readahead],
samba_cv_HAVE_LINUX_READAHEAD,[
-
AC_TRY_LINK([
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
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"
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
FLAGS1="-I\$(srcdir)/popt"
else
AC_MSG_RESULT(no)
- BUILD_POPT=""
+ BUILD_POPT=""
POPTLIBS="-lpopt"
fi
AC_SUBST(BUILD_POPT)
-#################################################
-# 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)
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
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)
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)
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
+++ /dev/null
-#! /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:
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);
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;