int main(int argc, char *argv[]) { char *desthost; pstring configfile; TimeInit(); setup_logging(argv[0],True); charset_initialise(); pstrcpy(configfile,CONFIGFILE); if (argc < 2) { fprintf(stderr,"smbfilter <desthost> <netbiosname>\n"); exit(1); } desthost = argv[1]; if (argc > 2) { netbiosname = argv[2]; } if (!lp_load(configfile,True,False,False)) { DEBUG(0,("Unable to load config file\n")); } start_filter(desthost); return 0; }
int main(int argc, char *argv[]) { extern char *optarg; extern int optind; extern FILE *dbf; int opt; dbf = fopen("/dev/null", "w"); if (!dbf) dbf = stderr; cgi_setup(WEB_ROOT); while ((opt = getopt(argc, argv,"s:")) != EOF) { switch (opt) { case 's': pstrcpy(servicesf,optarg); break; } } print_header(); charset_initialise(); if (load_config()) { cgi_load_variables(NULL); process_requests(); show_services(); } print_footer(); return 0; }
int main(int argc, char *argv[]) { const char *pszTemp; TimeInit(); setup_logging(argv[0],True); charset_initialise(); if (argc < 2 || argc > 3) printf("Usage: testprns printername [printcapfile]\n"); else { dbf = sys_fopen("test.log", "w"); if (dbf == NULL) { printf("Unable to open logfile.\n"); } else { DEBUGLEVEL = 3; pszTemp = (argc < 3) ? PRINTCAP_NAME : argv[2]; printf("Looking for printer %s in printcap file %s\n", argv[1], pszTemp); if (!pcap_printername_ok(argv[1], pszTemp)) printf("Printer name %s is not valid.\n", argv[1]); else printf("Printer name %s is valid.\n", argv[1]); fclose(dbf); } } return (0); }
int main(int argc, char *argv[]) { pid_t pid; int i, n; static pstring servicesf = CONFIGFILE; char buf[12]; TimeInit(); setup_logging(argv[0],True); charset_initialise(); lp_load(servicesf,False,False,False); message_init(); if (argc != 3) { fprintf(stderr, "%s: Usage - %s pid count\n", argv[0], argv[0]); exit(1); } pid = atoi(argv[1]); n = atoi(argv[2]); message_register(MSG_PONG, pong_message); for (i=0;i<n;i++) { message_send_pid(pid, MSG_PING, NULL, 0, True); } while (pong_count < i) { message_dispatch(); msleep(1); } /* Now test that the duplicate filtering code works. */ pong_count = 0; safe_strcpy(buf, "1234567890", sizeof(buf)-1); for (i=0;i<n;i++) { message_send_pid(getpid(), MSG_PING, NULL, 0, False); message_send_pid(getpid(), MSG_PING, buf, 11, False); } for (i=0;i<n;i++) { message_dispatch(); msleep(1); } if (pong_count != 2) { fprintf(stderr, "Duplicate filter failed (%d).\n", pong_count); exit(1); } return (0); }
int main(int argc, char **argv) { pstring servicesf = CONFIGFILE; /* Argument check */ if (argc == 1) { usage(); return 1; } /* Load smb.conf file */ charset_initialise(); if (!lp_load(servicesf,False,False,True)) { fprintf(stderr, "Couldn't load confiuration file %s\n", servicesf); return 1; } /* Do commands */ if (strcmp(argv[1], "setsec") == 0) { if (argc != 3) { usage(); return 1; } return psec_setsec(argv[2]); } if (strcmp(argv[1], "getsec") == 0) { if (argc != 3) { usage(); return 1; } return psec_getsec(argv[2]); } /* An unknown command */ printf("psec: unknown command %s\n", argv[1]); return 1; }
/**************************************************************************** main program ****************************************************************************/ int main(int argc,char *argv[]) { fstring base_directory; char *pname = argv[0]; int opt; extern FILE *dbf; extern char *optarg; extern int optind; pstring query_host; BOOL nt_domain_logon = False; static pstring servicesf = CONFIGFILE; pstring term_code; char *p; #ifdef KANJI pstrcpy(term_code, KANJI); #else /* KANJI */ *term_code = 0; #endif /* KANJI */ *query_host = 0; *base_directory = 0; DEBUGLEVEL = 2; setup_logging(pname,True); TimeInit(); charset_initialise(); pid = getpid(); uid = getuid(); gid = getgid(); mid = pid + 100; myumask = umask(0); umask(myumask); if (getenv("USER")) { pstrcpy(username,getenv("USER")); /* modification to support userid%passwd syntax in the USER var 25.Aug.97, [email protected] */ if ((p=strchr(username,'%'))) { *p = 0; pstrcpy(password,p+1); got_pass = True; memset(strchr(getenv("USER"),'%')+1,'X',strlen(password)); } strupper(username); } /* modification to support PASSWD environmental var 25.Aug.97, [email protected] */ if (getenv("PASSWD")) pstrcpy(password,getenv("PASSWD")); if (*username == 0 && getenv("LOGNAME")) { pstrcpy(username,getenv("LOGNAME")); strupper(username); } if (argc < 2) { usage(pname); exit(1); } if (*argv[1] != '-') { pstrcpy(service, argv[1]); /* Convert any '/' characters in the service name to '\' characters */ string_replace( service, '/','\\'); argc--; argv++; if (count_chars(service,'\\') < 3) { usage(pname); printf("\n%s: Not enough '\\' characters in service\n",service); exit(1); } if (argc > 1 && (*argv[1] != '-')) { got_pass = True; pstrcpy(password,argv[1]); memset(argv[1],'X',strlen(argv[1])); argc--; argv++; } } while ((opt = getopt(argc, argv,"s:B:O:M:S:i:Nn:d:Pp:l:hI:EB:U:L:t:m:W:T:D:c:")) != EOF) switch (opt) { case 'm': max_protocol = interpret_protocol(optarg,max_protocol); break; case 'O': pstrcpy(user_socket_options,optarg); break; case 'S': pstrcpy(desthost,optarg); strupper(desthost); nt_domain_logon = True; break; case 'B': iface_set_default(NULL,optarg,NULL); break; case 'D': pstrcpy(base_directory,optarg); break; case 'i': pstrcpy(scope,optarg); break; case 'U': { char *lp; pstrcpy(username,optarg); if ((lp=strchr(username,'%'))) { *lp = 0; pstrcpy(password,lp+1); got_pass = True; memset(strchr(optarg,'%')+1,'X',strlen(password)); } } break; case 'W': pstrcpy(workgroup,optarg); break; case 'E': dbf = stderr; break; case 'I': { dest_ip = *interpret_addr2(optarg); if (zero_ip(dest_ip)) exit(1); have_ip = True; } break; case 'n': pstrcpy(myname,optarg); break; case 'N': got_pass = True; break; case 'd': if (*optarg == 'A') DEBUGLEVEL = 10000; else DEBUGLEVEL = atoi(optarg); break; case 'l': slprintf(debugf,sizeof(debugf)-1,"%s.client",optarg); break; case 'p': port = atoi(optarg); break; case 'c': cmdstr = optarg; got_pass = True; break; case 'h': usage(pname); exit(0); break; case 's': pstrcpy(servicesf, optarg); break; case 't': pstrcpy(term_code, optarg); break; default: usage(pname); exit(1); } if (!*query_host && !*service) { usage(pname); exit(1); } DEBUG(3,("%s client started (version %s)\n",timestring(),VERSION)); if(!get_myname(myhostname,NULL)) { DEBUG(0,("Failed to get my hostname.\n")); } if (!lp_load(servicesf,True)) { fprintf(stderr, "Can't load %s - run testparm to debug it\n", servicesf); } codepage_initialise(lp_client_code_page()); interpret_coding_system(term_code); if (*workgroup == 0) pstrcpy(workgroup,lp_workgroup()); load_interfaces(); get_myname((*myname)?NULL:myname,NULL); strupper(myname); #ifdef NTDOMAIN if (nt_domain_logon) { int ret = 0; slprintf(service,sizeof(service), "\\\\%s\\IPC$",query_host); strupper(service); connect_as_ipc = True; DEBUG(5,("NT Domain Logon. Service: %s\n", service)); if (cli_open_sockets(port)) { if (!cli_send_login(NULL,NULL,True,True,NULL)) return(1); do_nt_login(desthost, myhostname, Client, cnum); cli_send_logout(); close_sockets(); } return(ret); } #endif if (cli_open_sockets(port)) { if (!process(base_directory)) { close_sockets(); return(1); } close_sockets(); } else return(1); return(0); }
int main(int argc, char *argv[]) { FILE *f; pstring fname; int uid, c; static pstring servicesf = CONFIGFILE; extern char *optarg; int verbose = 0, brief =0; BOOL processes_only=False; int last_pid=0; struct session_record *ptr; TimeInit(); setup_logging(argv[0],True); charset_initialise(); DEBUGLEVEL = 0; dbf = fopen("/dev/null","w"); if (getuid() != geteuid()) { printf("smbstatus should not be run setuid\n"); return(1); } while ((c = getopt(argc, argv, "pds:u:b")) != EOF) { switch (c) { case 'b': brief = 1; break; case 'd': verbose = 1; break; case 'p': processes_only = 1; break; case 's': pstrcpy(servicesf, optarg); break; case 'u': /* added by OH */ Ucrit_addUsername(optarg); /* added by OH */ break; default: fprintf(stderr, "Usage: %s [-d] [-p] [-s configfile] [-u username]\n", *argv); /* changed by OH */ return (-1); } } get_myname(myhostname, NULL); if (!lp_load(servicesf,False)) { fprintf(stderr, "Can't load %s - run testparm to debug it\n", servicesf); return (-1); } if (verbose) { printf("using configfile = %s\n", servicesf); printf("lockdir = %s\n", *lp_lockdir() ? lp_lockdir() : "NULL"); } pstrcpy(fname,lp_lockdir()); standard_sub_basic(fname); trim_string(fname,"","/"); pstrcat(fname,"/STATUS..LCK"); f = fopen(fname,"r"); if (!f) { printf("Couldn't open status file %s\n",fname); if (!lp_status(-1)) printf("You need to have status=yes in your smb config file\n"); return(0); } else if (verbose) { printf("Opened status file %s\n", fname); } uid = getuid(); if (!processes_only) { printf("\nSamba version %s\n",VERSION); if (brief) { printf("PID Username Machine Time logged in\n"); printf("-------------------------------------------------------------------\n"); } else { printf("Service uid gid pid machine\n"); printf("----------------------------------------------\n"); } } while (!feof(f)) { if (fread(&crec,sizeof(crec),1,f) != 1) break; if ( crec.magic == 0x280267 && process_exists(crec.pid) && Ucrit_checkUsername(uidtoname(crec.uid)) /* added by OH */ ) { if (brief) { ptr=srecs; while (ptr!=NULL) { if ((ptr->pid==crec.pid)&&(strncmp(ptr->machine,crec.machine,30)==0)) { if (ptr->start > crec.start) ptr->start=crec.start; break; } ptr=ptr->next; } if (ptr==NULL) { ptr=(struct session_record *) malloc(sizeof(struct session_record)); ptr->uid=crec.uid; ptr->pid=crec.pid; ptr->start=crec.start; strncpy(ptr->machine,crec.machine,30); ptr->machine[30]='\0'; ptr->next=srecs; srecs=ptr; } } else { Ucrit_addPid(crec.pid); /* added by OH */ if (processes_only) { if (last_pid != crec.pid) printf("%d\n",crec.pid); last_pid = crec.pid; /* XXXX we can still get repeats, have to add a sort at some time */ } else printf("%-10.10s %-8s %-8s %5d %-8s (%s) %s", crec.name,uidtoname(crec.uid),gidtoname(crec.gid),crec.pid, crec.machine,crec.addr, asctime(LocalTime(&crec.start))); } } } fclose(f); if (processes_only) exit(0); if (brief) { ptr=srecs; while (ptr!=NULL) { printf("%-8d%-10.10s%-30.30s%s",ptr->pid,uidtoname(ptr->uid),ptr->machine,asctime(LocalTime(&(ptr->start)))); ptr=ptr->next; } printf("\n"); exit(0); } printf("\n"); locking_init(1); if (share_mode_forall(print_share_mode) <= 0) printf("No locked files\n"); printf("\n"); share_status(stdout); locking_end(); return (0); }
/***************************************************** initialise structures *******************************************************/ void smbw_init(void) { extern BOOL in_client; static int initialised; static pstring servicesf = CONFIGFILE; extern FILE *dbf; char *p; int eno; pstring line; if (initialised) return; initialised = 1; eno = errno; smbw_busy++; DEBUGLEVEL = 0; AllowDebugChange = False; setup_logging("smbsh",True); dbf = stderr; if ((p=smbw_getshared("LOGFILE"))) { dbf = sys_fopen(p, "a"); } smbw_file_bmap = bitmap_allocate(SMBW_MAX_OPEN); if (!smbw_file_bmap) { exit(1); } charset_initialise(); in_client = True; load_interfaces(); if ((p=smbw_getshared("SERVICESF"))) { pstrcpy(servicesf, p); } lp_load(servicesf,True,False,False); codepage_initialise(lp_client_code_page()); get_myname(global_myname); if ((p=smbw_getshared("DEBUG"))) { DEBUGLEVEL = atoi(p); } if ((p=smbw_getshared("RESOLVE_ORDER"))) { lp_set_name_resolve_order(p); } if ((p=smbw_getshared("PREFIX"))) { slprintf(smbw_prefix,sizeof(fstring)-1, "/%s/", p); all_string_sub(smbw_prefix,"//", "/", 0); DEBUG(2,("SMBW_PREFIX is %s\n", smbw_prefix)); } slprintf(line,sizeof(line)-1,"PWD_%d", (int)getpid()); p = smbw_getshared(line); if (!p) { sys_getwd(smbw_cwd); } pstrcpy(smbw_cwd, p); DEBUG(4,("Initial cwd is %s\n", smbw_cwd)); smbw_busy--; set_maxfiles(SMBW_MAX_OPEN); BlockSignals(True,SIGPIPE); errno = eno; }
/**************************************************************************** main program ****************************************************************************/ int main(int argc,char *argv[]) { char *pname = argv[0]; int opt; extern FILE *dbf; extern char *optarg; extern int optind; static pstring servicesf = CONFIGFILE; pstring term_code; BOOL got_pass = False; char *cmd_str=""; enum client_action cli_action = CLIENT_NONE; int nprocs = 1; int numops = 100; pstring logfile; struct client_info cli_info; out_hnd = stdout; rpcclient_init(); #ifdef KANJI pstrcpy(term_code, KANJI); #else /* KANJI */ *term_code = 0; #endif /* KANJI */ if (!lp_load(servicesf,True, False, False)) { fprintf(stderr, "Can't load %s - run testparm to debug it\n", servicesf); } codepage_initialise(lp_client_code_page()); DEBUGLEVEL = 0; cli_info.put_total_size = 0; cli_info.put_total_time_ms = 0; cli_info.get_total_size = 0; cli_info.get_total_time_ms = 0; cli_info.dir_total = 0; cli_info.newer_than = 0; cli_info.archive_level = 0; cli_info.print_mode = 1; cli_info.translation = False; cli_info.recurse_dir = False; cli_info.lowercase = False; cli_info.prompt = True; cli_info.abort_mget = True; cli_info.dest_ip.s_addr = 0; cli_info.name_type = 0x20; pstrcpy(cli_info.cur_dir , "\\"); pstrcpy(cli_info.file_sel, ""); pstrcpy(cli_info.base_dir, ""); pstrcpy(smb_cli->domain, ""); pstrcpy(smb_cli->user_name, ""); pstrcpy(cli_info.myhostname, ""); pstrcpy(cli_info.dest_host, ""); pstrcpy(cli_info.svc_type, "A:"); pstrcpy(cli_info.share, ""); pstrcpy(cli_info.service, ""); ZERO_STRUCT(cli_info.dom.level3_sid); pstrcpy(cli_info.dom.level3_dom, ""); ZERO_STRUCT(cli_info.dom.level5_sid); pstrcpy(cli_info.dom.level5_dom, ""); smb_cli->nt_pipe_fnum = 0xffff; setup_logging(pname, True); TimeInit(); charset_initialise(); if (!get_myname(global_myname)) { fprintf(stderr, "Failed to get my hostname.\n"); } password[0] = 0; if (argc < 2) { usage(pname); exit(1); } if (*argv[1] != '-') { pstrcpy(cli_info.service, argv[1]); /* Convert any '/' characters in the service name to '\' characters */ string_replace( cli_info.service, '/','\\'); argc--; argv++; DEBUG(1,("service: %s\n", cli_info.service)); if (count_chars(cli_info.service,'\\') < 3) { usage(pname); printf("\n%s: Not enough '\\' characters in service\n", cli_info.service); exit(1); } /* if (count_chars(cli_info.service,'\\') > 3) { usage(pname); printf("\n%s: Too many '\\' characters in service\n", cli_info.service); exit(1); } */ if (argc > 1 && (*argv[1] != '-')) { got_pass = True; pstrcpy(password,argv[1]); memset(argv[1],'X',strlen(argv[1])); argc--; argv++; } cli_action = CLIENT_SVC; } while ((opt = getopt(argc, argv,"s:O:M:S:i:N:o:n:d:l:hI:EB:U:L:t:m:W:T:D:c:")) != EOF) { switch (opt) { case 'm': { /* FIXME ... max_protocol seems to be funny here */ int max_protocol = 0; max_protocol = interpret_protocol(optarg,max_protocol); fprintf(stderr, "max protocol not currently supported\n"); break; } case 'O': { pstrcpy(user_socket_options,optarg); break; } case 'S': { pstrcpy(cli_info.dest_host,optarg); strupper(cli_info.dest_host); cli_action = CLIENT_IPC; break; } case 'i': { pstrcpy(scope, optarg); break; } case 'U': { char *lp; pstrcpy(smb_cli->user_name,optarg); if ((lp=strchr(smb_cli->user_name,'%'))) { *lp = 0; pstrcpy(password,lp+1); got_pass = True; memset(strchr(optarg,'%')+1,'X',strlen(password)); } break; } case 'W': { pstrcpy(smb_cli->domain,optarg); break; } case 'E': { dbf = stderr; break; } case 'I': { cli_info.dest_ip = *interpret_addr2(optarg); if (zero_ip(cli_info.dest_ip)) { exit(1); } break; } case 'N': { nprocs = atoi(optarg); break; } case 'o': { numops = atoi(optarg); break; } case 'n': { fstrcpy(global_myname, optarg); break; } case 'd': { if (*optarg == 'A') DEBUGLEVEL = 10000; else DEBUGLEVEL = atoi(optarg); break; } case 'l': { slprintf(logfile, sizeof(logfile)-1, "%s.client",optarg); lp_set_logfile(logfile); break; } case 'c': { cmd_str = optarg; got_pass = True; break; } case 'h': { usage(pname); exit(0); break; } case 's': { pstrcpy(servicesf, optarg); break; } case 't': { pstrcpy(term_code, optarg); break; } default: { usage(pname); exit(1); break; } } } if (cli_action == CLIENT_NONE) { usage(pname); exit(1); } strupper(global_myname); fstrcpy(cli_info.myhostname, global_myname); DEBUG(3,("%s client started (version %s)\n",timestring(False),VERSION)); if (*smb_cli->domain == 0) { pstrcpy(smb_cli->domain,lp_workgroup()); } strupper(smb_cli->domain); load_interfaces(); if (cli_action == CLIENT_IPC) { pstrcpy(cli_info.share, "IPC$"); pstrcpy(cli_info.svc_type, "IPC"); } fstrcpy(cli_info.mach_acct, cli_info.myhostname); strupper(cli_info.mach_acct); fstrcat(cli_info.mach_acct, "$"); /* set the password cache info */ if (got_pass) { if (password[0] == 0) { pwd_set_nullpwd(&(smb_cli->pwd)); } else { pwd_make_lm_nt_16(&(smb_cli->pwd), password); /* generate 16 byte hashes */ } } else { char *pwd = getpass("Enter Password:"); safe_strcpy(password, pwd, sizeof(password)); pwd_make_lm_nt_16(&(smb_cli->pwd), password); /* generate 16 byte hashes */ } create_procs(nprocs, numops, &cli_info, smb_cli, run_enums_test); if (password[0] != 0) { create_procs(nprocs, numops, &cli_info, smb_cli, run_ntlogin_test); } fflush(out_hnd); return(0); }
int pam_sm_chauthtok(pam_handle_t *pamh, int flags, int argc, const char **argv) { unsigned int ctrl; int retval; extern BOOL in_client; SAM_ACCOUNT *sampass = NULL; const char *user; char *pass_old, *pass_new; /* Samba initialization. */ setup_logging( "pam_smbpass", False ); charset_initialise(); codepage_initialise(lp_client_code_page()); in_client = True; ctrl = set_ctrl(flags, argc, argv); /* * First get the name of a user. No need to do anything if we can't * determine this. */ retval = pam_get_user( pamh, &user, "Username: "******"password: could not identify user" ); } return retval; } if (on( SMB_DEBUG, ctrl )) { _log_err( LOG_DEBUG, "username [%s] obtained", user ); } if (!initialize_password_db(True)) { _log_err( LOG_ALERT, "Cannot access samba password database" ); return PAM_AUTHINFO_UNAVAIL; } /* obtain user record */ pdb_init_sam(&sampass); pdb_getsampwnam(sampass,user); if (sampass == NULL) { _log_err( LOG_ALERT, "Failed to find entry for user %s.", user ); return PAM_USER_UNKNOWN; } if (flags & PAM_PRELIM_CHECK) { /* * obtain and verify the current password (OLDAUTHTOK) for * the user. */ char *Announce; if (_smb_blankpasswd( ctrl, sampass )) { pdb_free_sam(sampass); return PAM_SUCCESS; } /* Password change by root, or for an expired token, doesn't require authentication. Is this a good choice? */ if (getuid() != 0 && !(flags & PAM_CHANGE_EXPIRED_AUTHTOK)) { /* tell user what is happening */ #define greeting "Changing password for " Announce = (char *) malloc(sizeof(greeting)+strlen(user)); if (Announce == NULL) { _log_err(LOG_CRIT, "password: out of memory"); pdb_free_sam(sampass); return PAM_BUF_ERR; } strncpy( Announce, greeting, sizeof(greeting) ); strncpy( Announce+sizeof(greeting)-1, user, strlen(user)+1 ); #undef greeting set( SMB__OLD_PASSWD, ctrl ); retval = _smb_read_password( pamh, ctrl, Announce, "Current SMB password: "******"password - (old) token not obtained" ); pdb_free_sam(sampass); return retval; } /* verify that this is the password for this user */ retval = _smb_verify_password( pamh, sampass, pass_old, ctrl ); } else { pass_old = NULL; retval = PAM_SUCCESS; /* root doesn't have to */ } pass_old = NULL; pdb_free_sam(sampass); return retval; } else if (flags & PAM_UPDATE_AUTHTOK) { #if 0 /* We used to return when this flag was set, but that breaks password synchronization when /other/ tokens are expired. For now, we change the password whenever we're asked. SRL */ if (flags & PAM_CHANGE_EXPIRED_AUTHTOK) { pdb_free_sam(sampass); return PAM_SUCCESS; } #endif /* * obtain the proposed password */ /* * get the old token back. NULL was ok only if root [at this * point we assume that this has already been enforced on a * previous call to this function]. */ if (off( SMB_NOT_SET_PASS, ctrl )) { retval = pam_get_item( pamh, PAM_OLDAUTHTOK, (const void **)&pass_old ); } else { retval = pam_get_data( pamh, _SMB_OLD_AUTHTOK, (const void **)&pass_old ); if (retval == PAM_NO_MODULE_DATA) { pass_old = NULL; retval = PAM_SUCCESS; } } if (retval != PAM_SUCCESS) { _log_err( LOG_NOTICE, "password: user not authenticated" ); pdb_free_sam(sampass); return retval; } /* * use_authtok is to force the use of a previously entered * password -- needed for pluggable password strength checking * or other module stacking */ if (on( SMB_USE_AUTHTOK, ctrl )) { set( SMB_USE_FIRST_PASS, ctrl ); } retval = _smb_read_password( pamh, ctrl , NULL , "Enter new SMB password: "******"Retype new SMB password: "******"password: new password not obtained" ); } pass_old = NULL; /* tidy up */ pdb_free_sam(sampass); return retval; } /* * At this point we know who the user is and what they * propose as their new password. Verify that the new * password is acceptable. */ if (pass_new[0] == '\0') { /* "\0" password = NULL */ pass_new = NULL; } retval = _pam_smb_approve_pass(pamh, ctrl, pass_old, pass_new); if (retval != PAM_SUCCESS) { _log_err(LOG_NOTICE, "new password not acceptable"); pass_new = pass_old = NULL; /* tidy up */ pdb_free_sam(sampass); return retval; } /* * By reaching here we have approved the passwords and must now * rebuild the smb password file. */ /* update the password database */ retval = smb_update_db(pamh, ctrl, user, pass_new); if (retval == PAM_SUCCESS) { /* password updated */ _log_err( LOG_NOTICE, "password for (%s/%d) changed by (%s/%d)" , user, pdb_get_uid(sampass), uidtoname( getuid() ) , getuid() ); } else { _log_err( LOG_ERR, "password change failed for user %s" , user ); } pass_old = pass_new = NULL; if (sampass) { pdb_free_sam(sampass); sampass = NULL; } } else { /* something has broken with the library */ _log_err( LOG_ALERT, "password received unknown request" ); retval = PAM_ABORT; } if (sampass) { pdb_free_sam(sampass); sampass = NULL; } pdb_free_sam(sampass); return retval; }
int main(int argc, char *argv[]) { int opt; char temp[255]; extern char *optarg; extern int optind; pstring servicesf = CONFIGFILE; BOOL interactive = False; TimeInit(); setup_logging(argv[0],True); AllowDebugChange = False; DEBUGLEVEL = 0; charset_initialise(); if (argc < 2) usage(True); while ((opt = getopt(argc, argv,"is:d:")) != EOF) { switch (opt) { case 'd': DEBUGLEVEL = atoi(optarg); break; case 'i': interactive = True; break; case 's': pstrcpy(servicesf, optarg); break; default: printf("Unknown option %c (%d)\n", (char)opt, opt); usage(True); } } lp_load(servicesf,False,False,False); if (!message_init()) exit(1); argc -= optind; argv = &argv[optind]; if (!interactive) { if (argc < 2) usage(True); /* * We want to return !do_command so we get the * right shell semantics (0 = success, 1 = fail) */ return (!do_command(argv[0],argv[1], argc-2, argc > 2 ? &argv[2] : 0)); } while (True) { char *myargv[4]; int myargc; printf("smbcontrol> "); if (!fgets(temp, sizeof(temp)-1, stdin)) break; myargc = 0; while ((myargc < 4) && (myargv[myargc] = strtok(myargc?NULL:temp," \t\n"))) { myargc++; } if (!myargc) break; if (strequal(myargv[0],"q")) break; if (myargc < 2) usage(False); else if (!do_command(myargv[0],myargv[1],myargc-2,myargc > 2 ? &myargv[2] : 0)) usage(False); } return(0); }
/**************************************************************************** main program ****************************************************************************/ int main(int argc,char *argv[]) { char *share1, *share2; struct cli_state *cli1, *cli2; extern char *optarg; extern int optind; extern FILE *dbf; int opt; char *p; int seed; setlinebuf(stdout); dbf = stderr; if (argv[1][0] == '-' || argc < 3) { usage(); exit(1); } share1 = argv[1]; share2 = argv[2]; all_string_sub(share1,"/","\\",0); all_string_sub(share2,"/","\\",0); setup_logging(argv[0],True); argc -= 2; argv += 2; TimeInit(); charset_initialise(); if (getenv("USER")) { pstrcpy(username,getenv("USER")); } seed = time(NULL); while ((opt = getopt(argc, argv, "U:s:hm:f:a")) != EOF) { switch (opt) { case 'U': pstrcpy(username,optarg); p = strchr(username,'%'); if (p) { *p = 0; pstrcpy(password, p+1); got_pass = 1; } break; case 's': seed = atoi(optarg); break; case 'h': usage(); exit(1); case 'm': maskchars = optarg; break; case 'f': filechars = optarg; break; case 'a': showall = 1; break; default: printf("Unknown option %c (%d)\n", (char)opt, opt); exit(1); } } argc -= optind; argv += optind; DEBUG(0,("seed=%d\n", seed)); srandom(seed); cli1 = connect_one(share1); if (!cli1) { DEBUG(0,("Failed to connect to %s\n", share1)); exit(1); } cli2 = connect_one(share2); if (!cli2) { DEBUG(0,("Failed to connect to %s\n", share2)); exit(1); } test_mask(argc, argv, cli1, cli2); return(0); }
/**************************************************************************** main program ****************************************************************************/ int main(int argc,char *argv[]) { BOOL interactive = True; int opt; extern FILE *dbf; extern char *optarg; extern int optind; static pstring servicesf = CONFIGFILE; pstring term_code; char *p; BOOL got_pass = False; char *cmd_str=""; mode_t myumask = 0755; enum client_action cli_action = CLIENT_NONE; struct client_info cli_info; pstring password; /* local copy only, if one is entered */ out_hnd = stdout; fstrcpy(debugf, argv[0]); rpcclient_init(); #ifdef KANJI pstrcpy(term_code, KANJI); #else /* KANJI */ *term_code = 0; #endif /* KANJI */ DEBUGLEVEL = 2; cli_info.put_total_size = 0; cli_info.put_total_time_ms = 0; cli_info.get_total_size = 0; cli_info.get_total_time_ms = 0; cli_info.dir_total = 0; cli_info.newer_than = 0; cli_info.archive_level = 0; cli_info.print_mode = 1; cli_info.translation = False; cli_info.recurse_dir = False; cli_info.lowercase = False; cli_info.prompt = True; cli_info.abort_mget = True; cli_info.dest_ip.s_addr = 0; cli_info.name_type = 0x20; pstrcpy(cli_info.cur_dir , "\\"); pstrcpy(cli_info.file_sel, ""); pstrcpy(cli_info.base_dir, ""); pstrcpy(smb_cli->domain, ""); pstrcpy(smb_cli->user_name, ""); pstrcpy(cli_info.myhostname, ""); pstrcpy(cli_info.dest_host, ""); pstrcpy(cli_info.svc_type, "A:"); pstrcpy(cli_info.share, ""); pstrcpy(cli_info.service, ""); ZERO_STRUCT(cli_info.dom.level3_sid); ZERO_STRUCT(cli_info.dom.level5_sid); fstrcpy(cli_info.dom.level3_dom, ""); fstrcpy(cli_info.dom.level5_dom, ""); smb_cli->nt_pipe_fnum = 0xffff; TimeInit(); charset_initialise(); myumask = umask(0); umask(myumask); if (!get_myname(global_myname)) { fprintf(stderr, "Failed to get my hostname.\n"); } if (getenv("USER")) { pstrcpy(smb_cli->user_name,getenv("USER")); /* modification to support userid%passwd syntax in the USER var 25.Aug.97, [email protected] */ if ((p=strchr(smb_cli->user_name,'%'))) { *p = 0; pstrcpy(password,p+1); got_pass = True; memset(strchr(getenv("USER"),'%')+1,'X',strlen(password)); } strupper(smb_cli->user_name); } password[0] = 0; /* modification to support PASSWD environmental var 25.Aug.97, [email protected] */ if (getenv("PASSWD")) { pstrcpy(password,getenv("PASSWD")); } if (*smb_cli->user_name == 0 && getenv("LOGNAME")) { pstrcpy(smb_cli->user_name,getenv("LOGNAME")); strupper(smb_cli->user_name); } if (argc < 2) { usage(argv[0]); exit(1); } if (*argv[1] != '-') { pstrcpy(cli_info.service, argv[1]); /* Convert any '/' characters in the service name to '\' characters */ string_replace( cli_info.service, '/','\\'); argc--; argv++; fprintf(out_hnd, "service: %s\n", cli_info.service); if (count_chars(cli_info.service,'\\') < 3) { usage(argv[0]); printf("\n%s: Not enough '\\' characters in service\n", cli_info.service); exit(1); } /* if (count_chars(cli_info.service,'\\') > 3) { usage(pname); printf("\n%s: Too many '\\' characters in service\n", cli_info.service); exit(1); } */ if (argc > 1 && (*argv[1] != '-')) { got_pass = True; pstrcpy(password,argv[1]); memset(argv[1],'X',strlen(argv[1])); argc--; argv++; } cli_action = CLIENT_SVC; } while ((opt = getopt(argc, argv,"s:O:M:S:i:N:n:d:l:hI:EB:U:L:t:m:W:T:D:c:")) != EOF) { switch (opt) { case 'm': { /* FIXME ... max_protocol seems to be funny here */ int max_protocol = 0; max_protocol = interpret_protocol(optarg,max_protocol); fprintf(stderr, "max protocol not currently supported\n"); break; } case 'O': { pstrcpy(user_socket_options,optarg); break; } case 'S': { pstrcpy(cli_info.dest_host,optarg); strupper(cli_info.dest_host); cli_action = CLIENT_IPC; break; } case 'i': { extern pstring global_scope; pstrcpy(global_scope, optarg); strupper(global_scope); break; } case 'U': { char *lp; pstrcpy(smb_cli->user_name,optarg); if ((lp=strchr(smb_cli->user_name,'%'))) { *lp = 0; pstrcpy(password,lp+1); got_pass = True; memset(strchr(optarg,'%')+1,'X',strlen(password)); } break; } case 'W': { pstrcpy(smb_cli->domain,optarg); break; } case 'E': { dbf = stderr; break; } case 'I': { cli_info.dest_ip = *interpret_addr2(optarg); if (zero_ip(cli_info.dest_ip)) { exit(1); } break; } case 'n': { fstrcpy(global_myname, optarg); break; } case 'N': { got_pass = True; break; } case 'd': { if (*optarg == 'A') DEBUGLEVEL = 10000; else DEBUGLEVEL = atoi(optarg); break; } case 'l': { slprintf(debugf, sizeof(debugf)-1, "%s.client", optarg); interactive = False; break; } case 'c': { cmd_str = optarg; got_pass = True; break; } case 'h': { usage(argv[0]); exit(0); break; } case 's': { pstrcpy(servicesf, optarg); break; } case 't': { pstrcpy(term_code, optarg); break; } default: { usage(argv[0]); exit(1); break; } } } setup_logging(debugf, interactive); if (cli_action == CLIENT_NONE) { usage(argv[0]); exit(1); } strupper(global_myname); fstrcpy(cli_info.myhostname, global_myname); DEBUG(3,("%s client started (version %s)\n",timestring(False),VERSION)); if (!lp_load(servicesf,True, False, False)) { fprintf(stderr, "Can't load %s - run testparm to debug it\n", servicesf); } codepage_initialise(lp_client_code_page()); if (*smb_cli->domain == 0) pstrcpy(smb_cli->domain,lp_workgroup()); load_interfaces(); if (cli_action == CLIENT_IPC) { pstrcpy(cli_info.share, "IPC$"); pstrcpy(cli_info.svc_type, "IPC"); } fstrcpy(cli_info.mach_acct, cli_info.myhostname); strupper(cli_info.mach_acct); fstrcat(cli_info.mach_acct, "$"); /* set the password cache info */ if (got_pass) { if (password[0] == 0) { pwd_set_nullpwd(&(smb_cli->pwd)); } else { pwd_make_lm_nt_16(&(smb_cli->pwd), password); /* generate 16 byte hashes */ } } else { pwd_read(&(smb_cli->pwd), "Enter Password:"******"rpcclient_connect: smb_cli->fd:%d\n", smb_cli->fd)); if (smb_cli->fd <= 0) { fprintf(stderr, "warning: connection could not be established to %s<%02x>\n", cli_info.dest_host, cli_info.name_type); fprintf(stderr, "this version of smbclient may crash if you proceed\n"); exit(-1); } switch (cli_action) { case CLIENT_IPC: { process(&cli_info, cmd_str); break; } default: { fprintf(stderr, "unknown client action requested\n"); break; } } rpcclient_stop(); return(0); }
/**************************************************************************** main program ****************************************************************************/ int main(int argc,char *argv[]) { int opt; unsigned int lookup_type = 0x0; pstring lookup; extern int optind; extern char *optarg; BOOL find_master=False; int i; static pstring servicesf = CONFIGFILE; BOOL lookup_by_ip = False; DEBUGLEVEL = 1; /* Prevent smb.conf setting from overridding */ AllowDebugChange = False; *lookup = 0; TimeInit(); setup_logging(argv[0],True); charset_initialise(); while ((opt = getopt(argc, argv, "d:fB:U:i:s:SMrhART")) != EOF) switch (opt) { case 'B': bcast_addr = *interpret_addr2(optarg); got_bcast = True; use_bcast = True; break; case 'f': give_flags = True; break; case 'U': bcast_addr = *interpret_addr2(optarg); got_bcast = True; use_bcast = False; break; case 'T': translate_addresses = !translate_addresses; break; case 'i': { extern pstring global_scope; pstrcpy(global_scope,optarg); strupper(global_scope); } break; case 'M': find_master = True; break; case 'S': find_status = True; break; case 'R': recursion_desired = True; break; case 'd': DEBUGLEVEL = atoi(optarg); break; case 's': pstrcpy(servicesf, optarg); break; case 'r': RootPort = True; break; case 'h': usage(); exit(0); break; case 'A': lookup_by_ip = True; break; default: usage(); exit(1); } if (argc < 2) { usage(); exit(1); } if (!lp_load(servicesf,True,False,False)) { fprintf(stderr, "Can't load %s - run testparm to debug it\n", servicesf); } load_interfaces(); if (!open_sockets()) return(1); for (i=optind;i<argc;i++) { char *p; struct in_addr ip; fstrcpy(lookup,argv[i]); if(lookup_by_ip) { fstrcpy(lookup,"*"); ip = *interpret_addr2(argv[i]); do_node_status(ServerFD, lookup, lookup_type, ip); continue; } if (find_master) { if (*lookup == '-') { fstrcpy(lookup,"\01\02__MSBROWSE__\02"); lookup_type = 1; } else { lookup_type = 0x1d; } } p = strchr(lookup,'#'); if (p) { *p = '\0'; sscanf(++p,"%x",&lookup_type); } if (!query_one(lookup, lookup_type)) { printf( "name_query failed to find name %s", lookup ); if( 0 != lookup_type ) printf( "#%02x", lookup_type ); printf( "\n" ); } } return(0); }