-static int
-ChangeUser(const char *user)
-{
- struct passwd *pas;
-
- /*
- * Obtain password entry and change privilages
- */
-
- if ((pas = getpwnam(user)) == 0) {
- log("\011failed to get uid for %s", user);
- return(-1);
- }
- setenv("USER", pas->pw_name, 1);
- setenv("HOME", pas->pw_dir, 1);
- setenv("SHELL", def_sh, 1);
-
- /*
- * Change running state to the user in question
- */
-
- if (initgroups(user, pas->pw_gid) < 0) {
- log("\011initgroups failed: %s %m", user);
- return(-1);
- }
- /* drop all priviledges */
- if (setgid(pas->pw_gid) < 0) {
- log("\011setgid failed: %s %d", user, pas->pw_gid);
- return(-1);
- }
- if (setuid(pas->pw_uid) < 0) {
- log("\011setuid failed: %s %d", user, pas->pw_uid);
- return(-1);
- }
+ /*
+ * Change running state to the user in question
+ */
+ err_msg = change_identity_e2str(pas);
+ if (err_msg) {
+ crondlog("\011%s for user %s", err_msg, user);
+ return -1;
+ }