#define USENMB
-#define CNV_LANG(s) dos_to_unix(s,False)
-#define CNV_INPUT(s) unix_to_dos(s,True)
-
-
/****************************************************************************
write to a local file with CR/LF->LF translation if appropriate. return the
number taken from the buffer. This may not equal the number written.
****************************************************************************/
static void cmd_pwd(void)
{
- DEBUG(0,("Current directory is %s",CNV_LANG(service)));
- DEBUG(0,("%s\n",CNV_LANG(cur_dir)));
+ DEBUG(0,("Current directory is %s",service));
+ DEBUG(0,("%s\n",cur_dir));
}
if (next_token(NULL,buf,NULL,sizeof(buf)))
do_cd(buf);
else
- DEBUG(0,("Current directory is %s\n",CNV_LANG(cur_dir)));
+ DEBUG(0,("Current directory is %s\n",cur_dir));
}
if (do_this_one(finfo)) {
time_t t = finfo->mtime; /* the time is assumed to be passed as GMT */
DEBUG(0,(" %-30s%7.7s %8.0f %s",
- CNV_LANG(finfo->name),
+ finfo->name,
attrib_string(finfo->mode),
(double)finfo->size,
asctime(LocalTime(&t))));
strlen(next_file) - 2;
*save_ch = '\0';
}
- DEBUG(0,("\n%s\n",CNV_LANG(next_file)));
+ DEBUG(0,("\n%s\n",next_file));
if (save_ch)
{
*save_ch = '\\';
fnum = cli_open(cli, rname, O_RDONLY, DENY_NONE);
if (fnum == -1) {
- DEBUG(0,("%s opening remote file %s\n",cli_errstr(cli),CNV_LANG(rname)));
+ DEBUG(0,("%s opening remote file %s\n",cli_errstr(cli),rname));
return;
}
if (nread < size) {
DEBUG (0, ("Short read when getting file %s. Only got %ld bytes.\n",
- CNV_LANG(rname), (long)nread));
+ rname, (long)nread));
}
free(data);
if (finfo->mode & aDIR)
slprintf(quest,sizeof(pstring)-1,
- "Get directory %s? ",CNV_LANG(finfo->name));
+ "Get directory %s? ",finfo->name);
else
slprintf(quest,sizeof(pstring)-1,
- "Get file %s? ",CNV_LANG(finfo->name));
+ "Get file %s? ",finfo->name);
if (prompt && !yesno(quest)) return;
if (!dos_directory_exist(finfo->name,NULL) &&
dos_mkdir(finfo->name,0777) != 0) {
- DEBUG(0,("failed to create directory %s\n",CNV_LANG(finfo->name)));
+ DEBUG(0,("failed to create directory %s\n",finfo->name));
pstrcpy(cur_dir,saved_curdir);
return;
}
if (dos_chdir(finfo->name) != 0) {
- DEBUG(0,("failed to chdir to directory %s\n",CNV_LANG(finfo->name)));
+ DEBUG(0,("failed to chdir to directory %s\n",finfo->name));
pstrcpy(cur_dir,saved_curdir);
return;
}
{
if (!cli_mkdir(cli, name)) {
DEBUG(0,("%s making remote directory %s\n",
- cli_errstr(cli),CNV_LANG(name)));
+ cli_errstr(cli),name));
return(False);
}
fnum = cli_open(cli, rname, O_WRONLY|O_CREAT|O_TRUNC, DENY_NONE);
if (fnum == -1) {
- DEBUG(0,("%s opening remote file %s\n",cli_errstr(cli),CNV_LANG(rname)));
+ DEBUG(0,("%s opening remote file %s\n",cli_errstr(cli),rname));
return;
}
DEBUG(1,("putting file %s as %s ",lname,
- CNV_LANG(rname)));
+ rname));
buf = (char *)malloc(maxwrite);
while (!feof(f)) {
}
if (!cli_close(cli, fnum)) {
- DEBUG(0,("%s closing remote file %s\n",cli_errstr(cli),CNV_LANG(rname)));
+ DEBUG(0,("%s closing remote file %s\n",cli_errstr(cli),rname));
fclose(f);
if (buf) free(buf);
return;
return;
if (!cli_unlink(cli, mask)) {
- DEBUG(0,("%s deleting remote file %s\n",cli_errstr(cli),CNV_LANG(mask)));
+ DEBUG(0,("%s deleting remote file %s\n",cli_errstr(cli),mask));
}
}
if (!cli_rmdir(cli, mask)) {
DEBUG(0,("%s removing remote directory file %s\n",
- cli_errstr(cli),CNV_LANG(mask)));
+ cli_errstr(cli),mask));
}
}
cmd = p + 1;
}
- /* input language code to internal one */
- CNV_INPUT (line);
-
/* and get the first part of the command */
ptr = line;
if (!next_token(&ptr,tok,NULL,sizeof(tok))) continue;
if ((i = process_tok(tok)) >= 0) {
commands[i].fn();
} else if (i == -2) {
- DEBUG(0,("%s: command abbreviation ambiguous\n",CNV_LANG(tok)));
+ DEBUG(0,("%s: command abbreviation ambiguous\n",tok));
} else {
- DEBUG(0,("%s: command not found\n",CNV_LANG(tok)));
+ DEBUG(0,("%s: command not found\n",tok));
}
}
}
temp = (char *)NULL;
}
- snprintf( prompt_str, PROMPTSIZE - 1, "smb: %s> ", CNV_LANG(cur_dir) );
+ snprintf( prompt_str, PROMPTSIZE - 1, "smb: %s> ", cur_dir );
temp = readline( prompt_str ); /* We read the line here */
strncpy( line, temp, 1023 ); /* Maximum size of (pstring)line. Null is guarranteed. */
#else
/* display a prompt */
- DEBUG(0,("smb: %s> ", CNV_LANG(cur_dir)));
+ DEBUG(0,("smb: %s> ", cur_dir));
dbgflush( );
wait_keyboard();
break;
#endif
- /* input language code to internal one */
- CNV_INPUT (line);
-
/* special case - first char is ! */
if (*line == '!') {
system(line + 1);
if ((i = process_tok(tok)) >= 0) {
commands[i].fn();
} else if (i == -2) {
- DEBUG(0,("%s: command abbreviation ambiguous\n",CNV_LANG(tok)));
+ DEBUG(0,("%s: command abbreviation ambiguous\n",tok));
} else {
- DEBUG(0,("%s: command not found\n",CNV_LANG(tok)));
+ DEBUG(0,("%s: command not found\n",tok));
}
}
}
return(dirp->pos);
}
+/*******************************************************************************
+ This section manages a global directory cache.
+ (It should probably be split into a separate module. crh)
+********************************************************************************/
-/* -------------------------------------------------------------------------- **
- * This section manages a global directory cache.
- * (It should probably be split into a separate module. crh)
- * -------------------------------------------------------------------------- **
- */
-
-typedef struct
- {
+typedef struct {
ubi_dlNode node;
char *path;
char *name;
char *dname;
int snum;
- } dir_cache_entry;
+} dir_cache_entry;
static ubi_dlNewList( dir_cache );
+/*****************************************************************************
+ Add an entry to the directory cache.
+ Input: path -
+ name -
+ dname -
+ snum -
+ Output: None.
+*****************************************************************************/
+
void DirCacheAdd( char *path, char *name, char *dname, int snum )
- /* ------------------------------------------------------------------------ **
- * Add an entry to the directory cache.
- *
- * Input: path -
- * name -
- * dname -
- * snum -
- *
- * Output: None.
- *
- * ------------------------------------------------------------------------ **
- */
- {
+{
int pathlen;
int namelen;
dir_cache_entry *entry;
while( DIRCACHESIZE < dir_cache->count )
free( ubi_dlRemTail( dir_cache ) );
- } /* DirCacheAdd */
+}
+/*****************************************************************************
+ Search for an entry to the directory cache.
+ Input: path -
+ name -
+ snum -
+ Output: The dname string of the located entry, or NULL if the entry was
+ not found.
+
+ Notes: This uses a linear search, which is is okay because of
+ the small size of the cache. Use a splay tree or hash
+ for large caches.
+*****************************************************************************/
char *DirCacheCheck( char *path, char *name, int snum )
- /* ------------------------------------------------------------------------ **
- * Search for an entry to the directory cache.
- *
- * Input: path -
- * name -
- * snum -
- *
- * Output: The dname string of the located entry, or NULL if the entry was
- * not found.
- *
- * Notes: This uses a linear search, which is is okay because of
- * the small size of the cache. Use a splay tree or hash
- * for large caches.
- *
- * ------------------------------------------------------------------------ **
- */
- {
+{
dir_cache_entry *entry;
for( entry = (dir_cache_entry *)ubi_dlFirst( dir_cache );
}
return(NULL);
- } /* DirCacheCheck */
+}
+
+/*****************************************************************************
+ Remove all cache entries which have an snum that matches the input.
+ Input: snum -
+ Output: None.
+*****************************************************************************/
void DirCacheFlush(int snum)
- /* ------------------------------------------------------------------------ **
- * Remove all cache entries which have an snum that matches the input.
- *
- * Input: snum -
- *
- * Output: None.
- *
- * ------------------------------------------------------------------------ **
- */
{
dir_cache_entry *entry;
ubi_dlNodePtr next;
free( ubi_dlRemThis( dir_cache, entry ) );
entry = (dir_cache_entry *)next;
}
-} /* DirCacheFlush */
-
-/* -------------------------------------------------------------------------- **
- * End of the section that manages the global directory cache.
- * -------------------------------------------------------------------------- **
- */
-
-
+}
return(True);
}
+/***********************************************************
+ Code to check a plaintext password against smbpasswd entries.
+***********************************************************/
+
+static BOOL check_plaintext_password(char *user,char *old_passwd,
+ int old_passwd_size, struct smb_passwd **psmbpw)
+{
+ struct smb_passwd *smbpw = NULL;
+ uchar old_pw[16],old_ntpw[16];
+
+ become_root(False);
+ *psmbpw = smbpw = getsmbpwnam(user);
+ unbecome_root(False);
+
+ if (smbpw == NULL) {
+ DEBUG(0,("check_plaintext_password: getsmbpwnam returned NULL\n"));
+ return False;
+ }
+
+ if (smbpw->acct_ctrl & ACB_DISABLED) {
+ DEBUG(0,("check_plaintext_password: account %s disabled.\n", user));
+ return(False);
+ }
+
+ nt_lm_owf_gen(old_passwd,old_ntpw,old_pw);
+
+#ifdef DEBUG_PASSWORD
+ DEBUG(100,("check_plaintext_password: smbpw->smb_nt_passwd \n"));
+ dump_data(100,smbpw->smb_nt_passwd,16);
+ DEBUG(100,("check_plaintext_password: old_ntpw \n"));
+ dump_data(100,old_ntpw,16);
+ DEBUG(100,("check_plaintext_password: smbpw->smb_passwd \n"));
+ dump_data(100,smbpw->smb_passwd,16);
+ DEBUG(100,("check_plaintext_password: old_pw\n"));
+ dump_data(100,old_pw,16);
+#endif
+
+ if(memcmp(smbpw->smb_nt_passwd,old_ntpw,16) && memcmp(smbpw->smb_passwd,old_pw,16))
+ return(False);
+ else
+ return(True);
+}
+
/****************************************************************************
- set the user password
- ****************************************************************************/
+ Set the user password.
+*****************************************************************************/
+
static BOOL api_SetUserPassword(connection_struct *conn,uint16 vuid, char *param,char *data,
int mdrcnt,int mprcnt,
char **rdata,char **rparam,
(void)Get_Pwnam( user, True);
/*
- * Attempt the plaintext password change first.
- * Older versions of Windows seem to do this.
+ * Attempt to verify the old password against smbpasswd entries
+ * Win98 clients send old and new password in plaintext for this call.
*/
- if (password_ok(user, pass1,strlen(pass1),NULL) &&
- chgpasswd(user,pass1,pass2,False))
{
- SSVAL(*rparam,0,NERR_Success);
+ fstring saved_pass2;
+ struct smb_passwd *smbpw = NULL;
+
+ /*
+ * Save the new password as change_oem_password overwrites it
+ * with zeros.
+ */
+
+ fstrcpy(saved_pass2, pass2);
+
+ if (check_plaintext_password(user,pass1,strlen(pass1),&smbpw) &&
+ change_oem_password(smbpw,pass2,False))
+ {
+ SSVAL(*rparam,0,NERR_Success);
+
+ /*
+ * If unix password sync was requested, attempt to change
+ * the /etc/passwd database also. Return failure if this cannot
+ * be done.
+ */
+
+ if(lp_unix_password_sync() && !chgpasswd(user,pass1,saved_pass2,False))
+ SSVAL(*rparam,0,NERR_badpass);
+ }
+ }
+
+ /*
+ * If the above failed, attempt the plaintext password change.
+ * This tests against the /etc/passwd database only.
+ */
+
+ if(SVAL(*rparam,0) != NERR_Success)
+ {
+ if (password_ok(user, pass1,strlen(pass1),NULL) &&
+ chgpasswd(user,pass1,pass2,False))
+ {
+ SSVAL(*rparam,0,NERR_Success);
+ }
}
/*
* If the plaintext change failed, attempt
- * the encrypted. NT will generate this
- * after trying the samr method.
+ * the old encrypted method. NT will generate this
+ * after trying the samr method. Note that this
+ * method is done as a last resort as this
+ * password change method loses the NT password hash
+ * and cannot change the UNIX password as no plaintext
+ * is received.
*/
if(SVAL(*rparam,0) != NERR_Success)