summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/net.c16
-rw-r--r--source3/utils/net.h16
-rw-r--r--source3/utils/net_ads.c20
-rw-r--r--source3/utils/net_rap.c6
-rw-r--r--source3/utils/net_rpc.c23
-rw-r--r--source3/utils/net_time.c6
-rw-r--r--source3/utils/nmblookup.c4
-rw-r--r--source3/utils/pdbedit.c28
-rw-r--r--source3/utils/smbcacls.c14
-rw-r--r--source3/utils/smbcontrol.c6
-rw-r--r--source3/utils/smbpasswd.c4
-rw-r--r--source3/utils/testprns.c2
12 files changed, 71 insertions, 74 deletions
diff --git a/source3/utils/net.c b/source3/utils/net.c
index 37ceadc372..d463534e75 100644
--- a/source3/utils/net.c
+++ b/source3/utils/net.c
@@ -56,10 +56,10 @@
/************************************************************************************/
/* Yes, these buggers are globals.... */
-char *opt_requester_name = NULL;
-char *opt_host = NULL;
-char *opt_password = NULL;
-char *opt_user_name = NULL;
+const char *opt_requester_name = NULL;
+const char *opt_host = NULL;
+const char *opt_password = NULL;
+const char *opt_user_name = NULL;
BOOL opt_user_specified = False;
const char *opt_workgroup = NULL;
int opt_long_list_entries = 0;
@@ -67,11 +67,11 @@ int opt_reboot = 0;
int opt_force = 0;
int opt_port = 0;
int opt_maxusers = -1;
-char *opt_comment = "";
+const char *opt_comment = "";
int opt_flags = -1;
int opt_jobid = 0;
int opt_timeout = 0;
-char *opt_target_workgroup = NULL;
+const char *opt_target_workgroup = NULL;
static int opt_machine_pass = 0;
BOOL opt_have_ip = False;
@@ -536,6 +536,7 @@ static struct functable net_func[] = {
load_interfaces();
if (opt_machine_pass) {
+ char *user;
/* it is very useful to be able to make ads queries as the
machine account for testing purposes and for domain leave */
@@ -544,7 +545,8 @@ static struct functable net_func[] = {
exit(1);
}
- asprintf(&opt_user_name,"%s$", global_myname());
+ asprintf(&user,"%s$", global_myname());
+ opt_user_name = user;
opt_password = secrets_fetch_machine_password();
if (!opt_password) {
d_printf("ERROR: Unable to fetch machine password\n");
diff --git a/source3/utils/net.h b/source3/utils/net.h
index 86bdf2082e..6fa4bd6bce 100644
--- a/source3/utils/net.h
+++ b/source3/utils/net.h
@@ -37,20 +37,24 @@
extern int opt_maxusers;
-extern char *opt_comment;
+extern const char *opt_comment;
extern int opt_flags;
-extern char *opt_comment;
+extern const char *opt_comment;
-extern char *opt_target_workgroup;
+extern const char *opt_target_workgroup;
+extern const char *opt_workgroup;
extern int opt_long_list_entries;
extern int opt_reboot;
extern int opt_force;
extern int opt_timeout;
-extern char *opt_host;
-extern char *opt_user_name;
-extern char *opt_password;
+extern const char *opt_host;
+extern const char *opt_user_name;
+extern const char *opt_password;
extern BOOL opt_user_specified;
+extern BOOL opt_have_ip;
+extern struct in_addr opt_dest_ip;
+
extern const char *share_type[];
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c
index 72dbe49c16..25b6f23d2d 100644
--- a/source3/utils/net_ads.c
+++ b/source3/utils/net_ads.c
@@ -544,8 +544,10 @@ static int net_ads_leave(int argc, const char **argv)
}
if (!opt_password) {
- asprintf(&opt_user_name, "%s$", global_myname());
+ char *user_name;
+ asprintf(&user_name, "%s$", global_myname());
opt_password = secrets_fetch_machine_password();
+ opt_user_name = user_name;
}
if (!(ads = ads_startup())) {
@@ -566,6 +568,7 @@ static int net_ads_leave(int argc, const char **argv)
static int net_ads_join_ok(void)
{
+ char *user_name;
ADS_STRUCT *ads = NULL;
if (!secrets_init()) {
@@ -573,7 +576,8 @@ static int net_ads_join_ok(void)
return -1;
}
- asprintf(&opt_user_name, "%s$", global_myname());
+ asprintf(&user_name, "%s$", global_myname());
+ opt_user_name = user_name;
opt_password = secrets_fetch_machine_password();
if (!(ads = ads_startup())) {
@@ -743,11 +747,10 @@ static int net_ads_printer_publish(int argc, const char **argv)
{
ADS_STRUCT *ads;
ADS_STATUS rc;
- char *servername;
+ const char *servername;
struct cli_state *cli;
struct in_addr server_ip;
NTSTATUS nt_status;
- extern char *opt_workgroup;
TALLOC_CTX *mem_ctx = talloc_init("net_ads_printer_publish");
ADS_MODLIST mods = ads_init_mods(mem_ctx);
char *prt_dn, *srv_dn, **srv_cn;
@@ -853,8 +856,8 @@ static int net_ads_printer(int argc, const char **argv)
static int net_ads_password(int argc, const char **argv)
{
ADS_STRUCT *ads;
- char *auth_principal = opt_user_name;
- char *auth_password = opt_password;
+ const char *auth_principal = opt_user_name;
+ const char *auth_password = opt_password;
char *realm = NULL;
char *new_password = NULL;
char *c;
@@ -902,13 +905,16 @@ static int net_ads_change_localhost_pass(int argc, const char **argv)
char *host_principal;
char *hostname;
ADS_STATUS ret;
+ char *user_name;
if (!secrets_init()) {
DEBUG(1,("Failed to initialise secrets database\n"));
return -1;
}
- asprintf(&opt_user_name, "%s$", global_myname());
+ asprintf(&user_name, "%s$", global_myname());
+ opt_user_name = user_name;
+
opt_password = secrets_fetch_machine_password();
if (!(ads = ads_startup())) {
diff --git a/source3/utils/net_rap.c b/source3/utils/net_rap.c
index af0a6adbd2..8f3dd53fa6 100644
--- a/source3/utils/net_rap.c
+++ b/source3/utils/net_rap.c
@@ -204,7 +204,7 @@ static int rap_share_add(int argc, const char **argv)
strlcpy(sinfo.share_name, sharename, sizeof(sinfo.share_name));
sinfo.reserved1 = '\0';
sinfo.share_type = 0;
- sinfo.comment = opt_comment;
+ sinfo.comment = smb_xstrdup(opt_comment);
sinfo.perms = 0;
sinfo.maximum_users = opt_maxusers;
sinfo.active_users = 0;
@@ -644,7 +644,7 @@ static int rap_user_add(int argc, const char **argv)
userinfo.userflags = opt_flags;
userinfo.reserved1 = '\0';
- userinfo.comment = opt_comment;
+ userinfo.comment = smb_xstrdup(opt_comment);
userinfo.priv = 1;
userinfo.home_dir = NULL;
userinfo.logon_script = NULL;
@@ -757,7 +757,7 @@ static int rap_group_add(int argc, const char **argv)
/* BB check for length 21 or smaller explicitly ? BB */
safe_strcpy(grinfo.group_name, argv[0], sizeof(grinfo.group_name));
grinfo.reserved1 = '\0';
- grinfo.comment = opt_comment;
+ grinfo.comment = smb_xstrdup(opt_comment);
ret = cli_NetGroupAdd(cli, &grinfo);
cli_shutdown(cli);
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index 2b2a69eb99..e0390a1afb 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -1442,7 +1442,7 @@ static NTSTATUS rpc_shutdown_internals(const DOM_SID *domain_sid, struct cli_sta
int argc, const char **argv)
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- char *msg = "This machine will be shutdown shortly";
+ const char *msg = "This machine will be shutdown shortly";
uint32 timeout = 20;
uint16 flgs = 0;
BOOL reboot = opt_reboot;
@@ -1630,10 +1630,6 @@ static int rpc_trustdom_del(int argc, const char **argv)
* @return Integer status (0 means success)
**/
-extern char *opt_user_name;
-extern char *opt_password;
-extern char *opt_workgroup;
-
static int rpc_trustdom_establish(int argc, const char **argv)
{
struct cli_state *cli;
@@ -1669,7 +1665,6 @@ static int rpc_trustdom_establish(int argc, const char **argv)
* hence it should be set to remote domain name instead of ours
*/
if (opt_workgroup) {
- SAFE_FREE(opt_workgroup);
opt_workgroup = smb_xstrdup(domain_name);
};
@@ -1870,18 +1865,13 @@ static NTSTATUS rpc_query_domain_sid(const DOM_SID *domain_sid, struct cli_state
};
-extern char* opt_workgroup;
-extern char* opt_target_worgroup;
-extern char* opt_host;
-extern char* opt_password;
-
static int rpc_trustdom_list(int argc, const char **argv)
{
/* common variables */
TALLOC_CTX* mem_ctx;
struct cli_state *cli, *remote_cli;
NTSTATUS nt_status;
- char *domain_name = NULL;
+ const char *domain_name = NULL;
DOM_SID queried_dom_sid;
fstring ascii_sid, padding;
int ascii_dom_name_len;
@@ -1909,15 +1899,13 @@ static int rpc_trustdom_list(int argc, const char **argv)
* set domain and pdc name to local samba server (default)
* or to remote one given in command line
*/
- strupper(opt_workgroup);
- if (strcmp(opt_workgroup, lp_workgroup())) {
+
+ if (StrCaseCmp(opt_workgroup, lp_workgroup())) {
domain_name = opt_workgroup;
- if (opt_target_workgroup) SAFE_FREE(opt_target_workgroup);
opt_target_workgroup = opt_workgroup;
} else {
- safe_strcpy(pdc_name, global_myname(), FSTRING_LEN);
+ fstrcpy(pdc_name, global_myname());
domain_name = talloc_strdup(mem_ctx, lp_workgroup());
- if (opt_target_workgroup) SAFE_FREE(opt_target_workgroup);
opt_target_workgroup = domain_name;
};
@@ -2069,7 +2057,6 @@ static int rpc_trustdom_list(int argc, const char **argv)
/* set opt_* variables to remote domain */
strupper(trusting_dom_names[i]);
opt_workgroup = talloc_strdup(mem_ctx, trusting_dom_names[i]);
- if (opt_target_workgroup) SAFE_FREE(opt_target_workgroup);
opt_target_workgroup = opt_workgroup;
d_printf("%s%s", trusting_dom_names[i], padding);
diff --git a/source3/utils/net_time.c b/source3/utils/net_time.c
index 4cf923b1f7..40619a0796 100644
--- a/source3/utils/net_time.c
+++ b/source3/utils/net_time.c
@@ -65,9 +65,6 @@ done:
/* find the servers time on the opt_host host */
static time_t nettime(int *zone)
{
- extern BOOL opt_have_ip;
- extern struct in_addr opt_dest_ip;
- extern char *opt_host;
return cli_servertime(opt_host, opt_have_ip? &opt_dest_ip : NULL, zone);
}
@@ -155,9 +152,6 @@ static int net_time_zone(int argc, const char **argv)
int net_time(int argc, const char **argv)
{
time_t t;
- extern BOOL opt_have_ip;
- extern struct in_addr opt_dest_ip;
- extern char *opt_host;
struct functable func[] = {
{"SYSTEM", net_time_system},
{"SET", net_time_set},
diff --git a/source3/utils/nmblookup.c b/source3/utils/nmblookup.c
index 8106134699..017efc60ae 100644
--- a/source3/utils/nmblookup.c
+++ b/source3/utils/nmblookup.c
@@ -121,7 +121,7 @@ static char *query_flags(int flags)
/****************************************************************************
do a node status query
****************************************************************************/
-static void do_node_status(int fd, char *name, int type, struct in_addr ip)
+static void do_node_status(int fd, const char *name, int type, struct in_addr ip)
{
struct nmb_name nname;
int count, i, j;
@@ -150,7 +150,7 @@ static void do_node_status(int fd, char *name, int type, struct in_addr ip)
/****************************************************************************
send out one query
****************************************************************************/
-static BOOL query_one(char *lookup, unsigned int lookup_type)
+static BOOL query_one(const char *lookup, unsigned int lookup_type)
{
int j, count, flags = 0;
struct in_addr *ip_list=NULL;
diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c
index 2b356095c5..3904f25154 100644
--- a/source3/utils/pdbedit.c
+++ b/source3/utils/pdbedit.c
@@ -231,7 +231,10 @@ static int print_users_list (struct pdb_context *in, BOOL verbosity, BOOL smbpwd
Set User Info
**********************************************************/
-static int set_user_info (struct pdb_context *in, char *username, char *fullname, char *homedir, char *drive, char *script, char *profile)
+static int set_user_info (struct pdb_context *in, const char *username,
+ const char *fullname, const char *homedir,
+ const char *drive, const char *script,
+ const char *profile)
{
SAM_ACCOUNT *sam_pwent=NULL;
BOOL ret;
@@ -270,7 +273,7 @@ static int set_user_info (struct pdb_context *in, char *username, char *fullname
/*********************************************************
Add New User
**********************************************************/
-static int new_user (struct pdb_context *in, char *username, char *fullname, char *homedir, char *drive, char *script, char *profile)
+static int new_user (struct pdb_context *in, const char *username, const char *fullname, const char *homedir, const char *drive, const char *script, const char *profile)
{
SAM_ACCOUNT *sam_pwent=NULL;
struct passwd *pwd = NULL;
@@ -339,26 +342,27 @@ static int new_user (struct pdb_context *in, char *username, char *fullname, cha
Add New Machine
**********************************************************/
-static int new_machine (struct pdb_context *in, char *machinename)
+static int new_machine (struct pdb_context *in, const char *machine_in)
{
SAM_ACCOUNT *sam_pwent=NULL;
+ fstring machinename;
char name[16];
- char *password = NULL;
if (!NT_STATUS_IS_OK(pdb_init_sam (&sam_pwent))) {
return -1;
}
+ fstrcpy(machinename, machine_in);
+
if (machinename[strlen (machinename) -1] == '$')
machinename[strlen (machinename) -1] = '\0';
+ strlower_m(machinename);
+
safe_strcpy (name, machinename, 16);
safe_strcat (name, "$", 16);
-
- string_set (&password, machinename);
- strlower_m(password);
-
- pdb_set_plaintext_passwd (sam_pwent, password);
+
+ pdb_set_plaintext_passwd (sam_pwent, machinename);
pdb_set_username (sam_pwent, name, PDB_CHANGED);
@@ -381,7 +385,7 @@ static int new_machine (struct pdb_context *in, char *machinename)
Delete user entry
**********************************************************/
-static int delete_user_entry (struct pdb_context *in, char *username)
+static int delete_user_entry (struct pdb_context *in, const char *username)
{
SAM_ACCOUNT *samaccount = NULL;
@@ -401,7 +405,7 @@ static int delete_user_entry (struct pdb_context *in, char *username)
Delete machine entry
**********************************************************/
-static int delete_machine_entry (struct pdb_context *in, char *machinename)
+static int delete_machine_entry (struct pdb_context *in, const char *machinename)
{
char name[16];
SAM_ACCOUNT *samaccount = NULL;
@@ -438,7 +442,7 @@ int main (int argc, char **argv)
uint32 setparms, checkparms;
int opt;
static char *full_name = NULL;
- static char *user_name = NULL;
+ static const char *user_name = NULL;
static char *home_dir = NULL;
static char *home_drive = NULL;
static char *backend = NULL;
diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c
index 07b2aa7fec..e41edcf6f8 100644
--- a/source3/utils/smbcacls.c
+++ b/source3/utils/smbcacls.c
@@ -43,13 +43,13 @@ enum chown_mode {REQUEST_NONE, REQUEST_CHOWN, REQUEST_CHGRP};
enum exit_values {EXIT_OK, EXIT_FAILED, EXIT_PARSE_ERROR};
struct perm_value {
- char *perm;
+ const char *perm;
uint32 mask;
};
/* These values discovered by inspection */
-static struct perm_value special_values[] = {
+static const struct perm_value special_values[] = {
{ "R", 0x00120089 },
{ "W", 0x00120116 },
{ "X", 0x001200a0 },
@@ -59,7 +59,7 @@ static struct perm_value special_values[] = {
{ NULL, 0 },
};
-static struct perm_value standard_values[] = {
+static const struct perm_value standard_values[] = {
{ "READ", 0x001200a9 },
{ "CHANGE", 0x001301bf },
{ "FULL", 0x001f01ff },
@@ -70,7 +70,7 @@ static struct cli_state *global_hack_cli;
static POLICY_HND pol;
static BOOL got_policy_hnd;
-static struct cli_state *connect_one(char *share);
+static struct cli_state *connect_one(const char *share);
/* Open cli connection and policy handle */
@@ -161,7 +161,7 @@ static BOOL StringToSid(DOM_SID *sid, const char *str)
/* print an ACE on a FILE, using either numeric or ascii representation */
static void print_ace(FILE *f, SEC_ACE *ace)
{
- struct perm_value *v;
+ const struct perm_value *v;
fstring sidstr;
int do_print = 0;
uint32 got_mask;
@@ -234,7 +234,7 @@ static BOOL parse_ace(SEC_ACE *ace, char *str)
unsigned atype, aflags, amask;
DOM_SID sid;
SEC_ACCESS mask;
- struct perm_value *v;
+ const struct perm_value *v;
ZERO_STRUCTP(ace);
p = strchr_m(str,':');
@@ -708,7 +708,7 @@ static int cacl_set(struct cli_state *cli, char *filename,
/*****************************************************
return a connection to a server
*******************************************************/
-static struct cli_state *connect_one(char *share)
+static struct cli_state *connect_one(const char *share)
{
struct cli_state *c;
struct in_addr ip;
diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index f4d197147f..10ebf019c5 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -24,8 +24,8 @@
extern BOOL AllowDebugChange;
-static struct {
- char *name;
+static const struct {
+ const char *name;
int value;
} msg_types[] = {
{"debug", MSG_DEBUG},
@@ -149,7 +149,7 @@ Prints out the current Profile level returned by MSG_PROFILELEVEL
void profilelevel_function(int msg_type, pid_t src, void *buf, size_t len)
{
int level;
- char *s=NULL;
+ const char *s=NULL;
memcpy(&level, buf, sizeof(int));
if (level) {
diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c
index bcb5629f21..577e467fbd 100644
--- a/source3/utils/smbpasswd.c
+++ b/source3/utils/smbpasswd.c
@@ -33,7 +33,7 @@ static BOOL got_pass = False, got_username = False;
static BOOL stdin_passwd_get = False;
static fstring user_name, user_password;
static char *new_passwd = NULL;
-static char *remote_machine = NULL;
+static const char *remote_machine = NULL;
static fstring ldap_secret;
@@ -241,7 +241,7 @@ static char *stdin_new_passwd(void)
Used if the '-s' option is set to silently get passwords
to enable scripting.
*************************************************************/
-static char *get_pass( char *prompt, BOOL stdin_get)
+static char *get_pass( const char *prompt, BOOL stdin_get)
{
char *p;
if (stdin_get) {
diff --git a/source3/utils/testprns.c b/source3/utils/testprns.c
index 1c13bb4ce3..7e52b86afb 100644
--- a/source3/utils/testprns.c
+++ b/source3/utils/testprns.c
@@ -34,7 +34,7 @@
int main(int argc, char *argv[])
{
- char *pszTemp;
+ const char *pszTemp;
setup_logging(argv[0],True);