* po/POTFILES.in, lib/tcbfuncs.c: Add more strings for

translation.
	* lib/tcbfuncs.c: Indicate the name of the program in error
	messages. Avoid perror.
	* src/useradd.c: Re-indent.
	* src/useradd.c: Add more strings for translation. Indicate the
	name of the program in error messages.
	* src/userdel.c: Re-indent.
	* src/userdel.c: Add more strings for translation. Indicate the
	name of the program in error messages.
This commit is contained in:
nekral-guest 2010-03-16 19:14:54 +00:00
parent ad694905be
commit c5fc8dd75d
5 changed files with 71 additions and 57 deletions

View File

@ -1,3 +1,16 @@
2010-03-15 Nicolas François <nicolas.francois@centraliens.net>
* po/POTFILES.in, lib/tcbfuncs.c: Add more strings for
translation.
* lib/tcbfuncs.c: Indicate the name of the program in error
messages. Avoid perror.
* src/useradd.c: Re-indent.
* src/useradd.c: Add more strings for translation. Indicate the
name of the program in error messages.
* src/userdel.c: Re-indent.
* src/userdel.c: Add more strings for translation. Indicate the
name of the program in error messages.
2010-03-15 Nicolas François <nicolas.francois@centraliens.net> 2010-03-15 Nicolas François <nicolas.francois@centraliens.net>
* src/usermod.c: user_newname and user_newid cannot be used to * src/usermod.c: user_newname and user_newid cannot be used to

View File

@ -63,7 +63,7 @@ int shadowtcb_gain_priv()
* to exit soon. * to exit soon.
*/ */
#define OUT_OF_MEMORY do { \ #define OUT_OF_MEMORY do { \
fprintf(stderr, "Out of memory.\n"); \ fprintf(stderr, _("%s: out of memory\n"), Prog); \
fflush(stderr); \ fflush(stderr); \
return 0; \ return 0; \
} while(0) } while(0)
@ -101,7 +101,7 @@ static char *shadowtcb_path_rel_existing(const char *name)
OUT_OF_MEMORY; OUT_OF_MEMORY;
} }
if (lstat(path, &st)) { if (lstat(path, &st)) {
fprintf(stderr, "Cannot stat %s: %s\n", path, strerror(errno)); fprintf(stderr, _("%s: Cannot stat %s: %s\n"), Prog, path, strerror(errno));
free(path); free(path);
return NULL; return NULL;
} }
@ -114,19 +114,19 @@ static char *shadowtcb_path_rel_existing(const char *name)
return rval; return rval;
} }
if (!S_ISLNK(st.st_mode)) { if (!S_ISLNK(st.st_mode)) {
fprintf(stderr, "%s is neither a directory, nor a symlink.\n", path); fprintf(stderr, _("%s: %s is neither a directory, nor a symlink.\n"), Prog, path);
free(path); free(path);
return NULL; return NULL;
} }
ret = readlink(path, link, sizeof(link) - 1); ret = readlink(path, link, sizeof(link) - 1);
free(path); free(path);
if (ret == -1) { if (ret == -1) {
perror("readlink"); fprintf(stderr, _("%s: Cannot read symbolic link %s: %s\n"), Prog, path, strerror(errno));
return NULL; return NULL;
} }
if (ret >= sizeof(link) - 1) { if (ret >= sizeof(link) - 1) {
link[sizeof(link) - 1] = '\0'; link[sizeof(link) - 1] = '\0';
fprintf(stderr, "Suspiciously long symlink: %s\n", link); fprintf(stderr, _("%s: Suspiciously long symlink: %s\n"), Prog, link);
return NULL; return NULL;
} }
link[ret] = '\0'; link[ret] = '\0';
@ -174,7 +174,7 @@ static int mkdir_leading(const char *name, uid_t uid)
return 0; return 0;
ptr = path; ptr = path;
if (stat(TCB_DIR, &st)) { if (stat(TCB_DIR, &st)) {
perror("stat"); fprintf(stderr, _("%s: Cannot stat %s: %s\n"), Prog, TCB_DIR, strerror(errno));
goto out_free_path; goto out_free_path;
} }
while ((ind = strchr(ptr, '/'))) { while ((ind = strchr(ptr, '/'))) {
@ -184,15 +184,15 @@ static int mkdir_leading(const char *name, uid_t uid)
OUT_OF_MEMORY; OUT_OF_MEMORY;
} }
if (mkdir(dir, 0700) && errno != EEXIST) { if (mkdir(dir, 0700) && errno != EEXIST) {
perror("mkdir"); fprintf(stderr, _("%s: Cannot create directory %s: %s\n"), Prog, dir, strerror(errno));
goto out_free_dir; goto out_free_dir;
} }
if (chown(dir, 0, st.st_gid)) { if (chown(dir, 0, st.st_gid)) {
perror("chown"); fprintf(stderr, _("%s: Cannot change owner of %s: %s\n"), Prog, dir, strerror(errno));
goto out_free_dir; goto out_free_dir;
} }
if (chmod(dir, 0711)) { if (chmod(dir, 0711)) {
perror("chmod"); fprintf(stderr, _("%s: Cannot change mode of %s: %s\n"), Prog, dir, strerror(errno));
goto out_free_dir; goto out_free_dir;
} }
free(dir); free(dir);
@ -220,8 +220,7 @@ static int unlink_suffs(const char *user)
OUT_OF_MEMORY; OUT_OF_MEMORY;
} }
if (unlink(tmp) && errno != ENOENT) { if (unlink(tmp) && errno != ENOENT) {
fprintf(stderr, "unlink: %s: %s\n", tmp, fprintf(stderr, _("%s: unlink: %s: %s\n"), Prog, tmp, strerror(errno));
strerror(errno));
free(tmp); free(tmp);
return 0; return 0;
} }
@ -244,7 +243,7 @@ static int rmdir_leading(char *path)
} }
if (rmdir(dir)) { if (rmdir(dir)) {
if (errno != ENOTEMPTY) { if (errno != ENOTEMPTY) {
perror("rmdir"); fprintf(stderr, _("%s: Cannot removedirectory %s: %s\n"), Prog, dir, strerror(errno));
ret = 0; ret = 0;
} }
free(dir); free(dir);
@ -268,7 +267,7 @@ static int move_dir(const char *user_newname, uid_t user_newid)
if (!olddir) if (!olddir)
goto out_free_nomem; goto out_free_nomem;
if (stat(olddir, &oldmode)) { if (stat(olddir, &oldmode)) {
perror("stat"); fprintf(stderr, _("%s: Cannot stat %s: %s\n"), Prog, olddir, strerror(errno));
goto out_free; goto out_free;
} }
old_uid = oldmode.st_uid; old_uid = oldmode.st_uid;
@ -286,13 +285,13 @@ static int move_dir(const char *user_newname, uid_t user_newid)
if (!mkdir_leading(user_newname, the_newid)) if (!mkdir_leading(user_newname, the_newid))
goto out_free; goto out_free;
if (rename(real_old_dir, real_new_dir)) { if (rename(real_old_dir, real_new_dir)) {
perror("rename"); fprintf(stderr, _("%s: Cannot rename %s to %s: %s\n"), Prog, real_old_dir, real_new_dir, strerror(errno));
goto out_free; goto out_free;
} }
if (!rmdir_leading(real_old_dir_rel)) if (!rmdir_leading(real_old_dir_rel))
goto out_free; goto out_free;
if (unlink(olddir) && errno != ENOENT) { if (unlink(olddir) && errno != ENOENT) {
perror("unlink"); fprintf(stderr, _("%s: Cannot remove %s: %s\n"), Prog, olddir, strerror(errno));
goto out_free; goto out_free;
} }
asprintf(&newdir, TCB_DIR "/%s", user_newname); asprintf(&newdir, TCB_DIR "/%s", user_newname);
@ -301,13 +300,13 @@ static int move_dir(const char *user_newname, uid_t user_newid)
if (!(real_new_dir_rel = shadowtcb_path_rel(user_newname, the_newid))) if (!(real_new_dir_rel = shadowtcb_path_rel(user_newname, the_newid)))
goto out_free; goto out_free;
if (strcmp(real_new_dir, newdir) && symlink(real_new_dir_rel, newdir)) { if (strcmp(real_new_dir, newdir) && symlink(real_new_dir_rel, newdir)) {
perror("symlink"); fprintf(stderr, _("%s: Cannot create symbolic link %s: %s\n"), Prog, real_new_dir_rel, strerror(errno));
goto out_free; goto out_free;
} }
ret = 1; ret = 1;
goto out_free; goto out_free;
out_free_nomem: out_free_nomem:
fprintf(stderr, "Out of memory\n"); fprintf(stderr, _("%s: out of memory\n"), Prog); \
fflush(stderr); fflush(stderr);
out_free: out_free:
free(olddir); free(olddir);
@ -386,48 +385,48 @@ int shadowtcb_move(const char *user_newname, uid_t user_newid)
OUT_OF_MEMORY; OUT_OF_MEMORY;
} }
if (stat(tcbdir, &dirmode)) { if (stat(tcbdir, &dirmode)) {
perror("stat"); fprintf(stderr, _("%s: Cannot stat %s: %s\n"), Prog, tcbdir, strerror(errno));
goto out_free; goto out_free;
} }
if (chown(tcbdir, 0, 0)) { if (chown(tcbdir, 0, 0)) {
perror("chown"); fprintf(stderr, _("%s: Cannot change owners of %s: %s\n"), Prog, tcbdir, strerror(errno));
goto out_free; goto out_free;
} }
if (chmod(tcbdir, 0700)) { if (chmod(tcbdir, 0700)) {
perror("chmod"); fprintf(stderr, _("%s: Cannot change mode of %s: %s\n"), Prog, tcbdir, strerror(errno));
goto out_free; goto out_free;
} }
if (lstat(shadow, &filemode)) { if (lstat(shadow, &filemode)) {
if (errno != ENOENT) { if (errno != ENOENT) {
perror("lstat"); fprintf(stderr, _("%s: Cannot lstat %s: %s\n"), Prog, shadow, strerror(errno));
goto out_free; goto out_free;
} }
fprintf(stderr, fprintf(stderr,
"Warning, user %s has no tcb shadow file.\n", _("%s: Warning, user %s has no tcb shadow file.\n"),
user_newname); Prog, user_newname);
} else { } else {
if (!S_ISREG(filemode.st_mode) || if (!S_ISREG(filemode.st_mode) ||
filemode.st_nlink != 1) { filemode.st_nlink != 1) {
fprintf(stderr, fprintf(stderr,
"Emergency: %s's tcb shadow is not a regular file" _("%s: Emergency: %s's tcb shadow is not a regular file"
" with st_nlink=1.\n" " with st_nlink=1.\n"
"The account is left locked.\n", "The account is left locked.\n"),
user_newname); Prog, user_newname);
goto out_free; goto out_free;
} }
if (chown(shadow, user_newid, filemode.st_gid)) { if (chown(shadow, user_newid, filemode.st_gid)) {
perror("chown"); fprintf(stderr, _("%s: Cannot change owner of %s: %s\n"), Prog, shadow, strerror(errno));
goto out_free; goto out_free;
} }
if (chmod(shadow, filemode.st_mode & 07777)) { if (chmod(shadow, filemode.st_mode & 07777)) {
perror("chmod"); fprintf(stderr, _("%s: Cannot change mode of %s: %s\n"), Prog, shadow, strerror(errno));
goto out_free; goto out_free;
} }
} }
if (!unlink_suffs(user_newname)) if (!unlink_suffs(user_newname))
goto out_free; goto out_free;
if (chown(tcbdir, user_newid, dirmode.st_gid)) { if (chown(tcbdir, user_newid, dirmode.st_gid)) {
perror("chown"); fprintf(stderr, _("%s: Cannot change owner of %s: %s\n"), Prog, tcbdir, strerror(errno));
goto out_free; goto out_free;
} }
ret = 1; ret = 1;
@ -448,7 +447,7 @@ int shadowtcb_create(const char *name, uid_t uid)
if (!getdef_bool("USE_TCB")) if (!getdef_bool("USE_TCB"))
return 1; return 1;
if (stat(TCB_DIR, &tcbdir_stat)) { if (stat(TCB_DIR, &tcbdir_stat)) {
perror("stat"); fprintf(stderr, _("%s: Cannot stat %s: %s\n"), Prog, tcbdir, strerror(errno));
return 0; return 0;
} }
shadowgid = tcbdir_stat.st_gid; shadowgid = tcbdir_stat.st_gid;
@ -465,30 +464,30 @@ int shadowtcb_create(const char *name, uid_t uid)
OUT_OF_MEMORY; OUT_OF_MEMORY;
} }
if (mkdir(dir, 0700)) { if (mkdir(dir, 0700)) {
fprintf(stderr, "mkdir: %s: %s\n", dir, strerror(errno)); fprintf(stderr, _("%s: mkdir: %s: %s\n"), Prog, dir, strerror(errno));
goto out_free; goto out_free;
return 0; return 0;
} }
fd = open(shadow, O_RDWR | O_CREAT | O_TRUNC, 0600); fd = open(shadow, O_RDWR | O_CREAT | O_TRUNC, 0600);
if (fd < 0) { if (fd < 0) {
perror("open"); fprintf(stderr, _("%s: Cannot open %s: %s\n"), Prog, shadow, strerror(errno));
goto out_free; goto out_free;
} }
close(fd); close(fd);
if (chown(shadow, 0, authgid)) { if (chown(shadow, 0, authgid)) {
perror("chown"); fprintf(stderr, _("%s: Cannot change owner of %s: %s\n"), Prog, shadow, strerror(errno));
goto out_free; goto out_free;
} }
if (chmod(shadow, authgid == shadowgid ? 0600 : 0640)) { if (chmod(shadow, authgid == shadowgid ? 0600 : 0640)) {
perror("chmod"); fprintf(stderr, _("%s: Cannot change mode of %s: %s\n"), Prog, shadow, strerror(errno));
goto out_free; goto out_free;
} }
if (chown(dir, 0, authgid)) { if (chown(dir, 0, authgid)) {
perror("chown"); fprintf(stderr, _("%s: Cannot change owner of %s: %s\n"), Prog, dir, strerror(errno));
goto out_free; goto out_free;
} }
if (chmod(dir, authgid == shadowgid ? 02700 : 02710)) { if (chmod(dir, authgid == shadowgid ? 02700 : 02710)) {
perror("chmod"); fprintf(stderr, _("%s: Cannot change mode of %s: %s\n"), Prog, dir, strerror(errno));
goto out_free; goto out_free;
} }
if (!shadowtcb_set_user(name) || !shadowtcb_move(NULL, uid)) if (!shadowtcb_set_user(name) || !shadowtcb_move(NULL, uid))

View File

@ -24,6 +24,7 @@ lib/shadow.c
lib/shadowio.c lib/shadowio.c
lib/shadowmem.c lib/shadowmem.c
lib/utent.c lib/utent.c
lib/tcbfuncs.c
libmisc/addgrps.c libmisc/addgrps.c
libmisc/age.c libmisc/age.c
libmisc/audit_help.c libmisc/audit_help.c

View File

@ -1312,7 +1312,7 @@ static void process_flags (int argc, char **argv)
if (!rflg) { if (!rflg) {
/* for system accounts defaults are ignored and we /* for system accounts defaults are ignored and we
* do not create a home dir */ * do not create a home dir */
if (getdef_bool("CREATE_HOME")) { if (getdef_bool ("CREATE_HOME")) {
mflg = true; mflg = true;
} }
} }
@ -2002,14 +2002,16 @@ int main (int argc, char **argv)
} }
#ifdef WITH_TCB #ifdef WITH_TCB
if (getdef_bool("USE_TCB")) { if (getdef_bool ("USE_TCB")) {
if (shadowtcb_create(user_name, user_id) == 0) { if (shadowtcb_create (user_name, user_id) == 0) {
fprintf(stderr, "Failed to create tcb directory for %s\n", user_name); fprintf (stderr,
_("%s: Failed to create tcb directory for %s\n"),
Prog, user_name);
fail_exit (E_UID_IN_USE); fail_exit (E_UID_IN_USE);
} }
} }
#endif #endif
open_shadow(); open_shadow ();
/* do we have to add a group for that user? This is why we need to /* do we have to add a group for that user? This is why we need to
* open the group files in the open_files() function --gafton */ * open the group files in the open_files() function --gafton */
@ -2039,7 +2041,7 @@ int main (int argc, char **argv)
} }
/* Do not create mail directory for system accounts */ /* Do not create mail directory for system accounts */
if( !rflg ) { if (!rflg) {
create_mail (); create_mail ();
} }

View File

@ -751,15 +751,15 @@ static int remove_tcbdir (const char *user_name, uid_t user_id)
buf = malloc (buflen); buf = malloc (buflen);
if (NULL == buf) { if (NULL == buf) {
fprintf (stderr, "Can't allocate memory, " fprintf (stderr, _("%s: Can't allocate memory, "
"tcb entry for %s not removed.\n", "tcb entry for %s not removed.\n"),
user_name); Prog, user_name);
return 1; return 1;
} }
snprintf (buf, buflen, TCB_DIR "/%s", user_name); snprintf (buf, buflen, TCB_DIR "/%s", user_name);
if (shadowtcb_drop_priv () == 0) { if (shadowtcb_drop_priv () == 0) {
fprintf (stderr, "Cannot drop privileges: %s\n", fprintf (stderr, _("%s: Cannot drop privileges: %s\n"),
strerror (errno)); Prog, strerror (errno));
shadowtcb_gain_priv (); shadowtcb_gain_priv ();
free (buf); free (buf);
return 1; return 1;
@ -768,8 +768,8 @@ static int remove_tcbdir (const char *user_name, uid_t user_id)
* We will regain them and remove the user's tcb directory afterwards. * We will regain them and remove the user's tcb directory afterwards.
*/ */
if (remove_tree (buf, false) != 0) { if (remove_tree (buf, false) != 0) {
fprintf (stderr, "Cannot remove the content of %s: %s\n", fprintf (stderr, _("%s: Cannot remove the content of %s: %s\n"),
buf, strerror (errno)); Prog, buf, strerror (errno));
shadowtcb_gain_priv (); shadowtcb_gain_priv ();
free (buf); free (buf);
return 1; return 1;
@ -777,8 +777,8 @@ static int remove_tcbdir (const char *user_name, uid_t user_id)
shadowtcb_gain_priv (); shadowtcb_gain_priv ();
free (buf); free (buf);
if (shadowtcb_remove (user_name) == 0) { if (shadowtcb_remove (user_name) == 0) {
fprintf (stderr, "Cannot remove tcb files for %s: %s\n", fprintf (stderr, _("%s: Cannot remove tcb files for %s: %s\n"),
user_name, strerror (errno)); Prog, user_name, strerror (errno));
ret = 1; ret = 1;
} }
return ret; return ret;
@ -920,12 +920,12 @@ int main (int argc, char **argv)
char *nis_master; char *nis_master;
fprintf (stderr, fprintf (stderr,
_("%s: user %s is a NIS user\n"), Prog, user_name); _("%s: user %s is a NIS user\n"), Prog, user_name);
if ( !yp_get_default_domain (&nis_domain) if ( !yp_get_default_domain (&nis_domain)
&& !yp_master (nis_domain, "passwd.byname", &nis_master)) { && !yp_master (nis_domain, "passwd.byname", &nis_master)) {
fprintf (stderr, fprintf (stderr,
_("%s: %s is the NIS master\n"), _("%s: %s is the NIS master\n"),
Prog, nis_master); Prog, nis_master);
} }
exit (E_NOTFOUND); exit (E_NOTFOUND);
} }
@ -996,9 +996,8 @@ int main (int argc, char **argv)
} }
if (path_prefix (user_home, pwd->pw_dir)) { if (path_prefix (user_home, pwd->pw_dir)) {
fprintf (stderr, fprintf (stderr,
_ _("%s: not removing directory %s (would remove home of user %s)\n"),
("%s: not removing directory %s (would remove home of user %s)\n"), Prog, user_home, pwd->pw_name);
Prog, user_home, pwd->pw_name);
rflg = false; rflg = false;
errors++; errors++;
/* continue */ /* continue */