summaryrefslogtreecommitdiff
path: root/source3/utils/net_ads.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2003-01-02 09:07:17 +0000
committerAndrew Bartlett <abartlet@samba.org>2003-01-02 09:07:17 +0000
commit6d66fb308ab85bd9691d541764e683e6040cf724 (patch)
tree10b705921665cb7bafdd332ca53b8a943e13f0e5 /source3/utils/net_ads.c
parentc105c12d122e599fe57dde8b2b73c52231f0c1d2 (diff)
downloadsamba-6d66fb308ab85bd9691d541764e683e6040cf724.tar.gz
samba-6d66fb308ab85bd9691d541764e683e6040cf724.tar.bz2
samba-6d66fb308ab85bd9691d541764e683e6040cf724.zip
BIG patch...
This patch makes Samba compile cleanly with -Wwrite-strings. - That is, all string literals are marked as 'const'. These strings are always read only, this just marks them as such for passing to other functions. What is most supprising is that I didn't need to change more than a few lines of code (all in 'net', which got a small cleanup of net.h and extern variables). The rest is just adding a lot of 'const'. As far as I can tell, I have not added any new warnings - apart from making all of tdbutil.c's function const (so they warn for adding that const string to struct). Andrew Bartlett (This used to be commit 92a777d0eaa4fb3a1c7835816f93c6bdd456816d)
Diffstat (limited to 'source3/utils/net_ads.c')
-rw-r--r--source3/utils/net_ads.c20
1 files changed, 13 insertions, 7 deletions
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())) {