mode_t string_to_mode(char *mode_str, mode_t base);
// password helper functions
-int read_passwd(char * buff, int buflen, char* mesg);
-int update_passwd(char *filename, char* username, char* encrypted);
+int read_password(char * buff, int buflen, char* mesg);
+int update_password(char *filename, char* username, char* encrypted);
#include <time.h>
-int read_passwd(char * buff, int buflen, char* mesg)
+int read_password(char * buff, int buflen, char* mesg)
{
int i = 0;
struct termios termio, oldtermio;
return current_ptr;
}
-int update_passwd(char *filename, char* username, char* encrypted)
+int update_password(char *filename, char* username, char* encrypted)
{
char *filenamesfx = NULL, *namesfx = NULL;
char *shadow = NULL, *sfx = NULL;
{
char *newp = NULL;
- if(read_passwd(toybuf, sizeof(toybuf), "New password:"))
+ if(read_password(toybuf, sizeof(toybuf), "New password:"))
return NULL; //may be due to Ctrl-C
newp = xstrdup(toybuf);
strength_check(newp, oldp, user);
- if(read_passwd(toybuf, sizeof(toybuf), "Retype password:")) {
+ if(read_password(toybuf, sizeof(toybuf), "Retype password:")) {
free(newp);
return NULL; //may be due to Ctrl-C
}
if(myuid != 0) {
/*Validate user */
- if(read_passwd(toybuf, sizeof(toybuf), "Origial password:")) {
+ if(read_password(toybuf, sizeof(toybuf), "Origial password:")) {
if(!toys.optargs[0]) free(name);
return;
}
/*Update the passwd */
if(pw->pw_passwd[0] == 'x')
- ret = update_passwd("/etc/shadow", name, encrypted);
+ ret = update_password("/etc/shadow", name, encrypted);
else
- ret = update_passwd("/etc/passwd", name, encrypted);
+ ret = update_password("/etc/passwd", name, encrypted);
if((toys.optflags & (FLAG_l | FLAG_u | FLAG_d)))
free(encrypted);