From dbe7a84c3eadd8188f8c253ba9664bb26e52c471 Mon Sep 17 00:00:00 2001 From: Luke De Mouy Date: Wed, 13 Jan 2016 18:04:14 -0700 Subject: [PATCH] Simply password changing code so that it doesn't repeat itself between being and not being in a chroot --- src/library/sysadm-usermanager.cpp | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/src/library/sysadm-usermanager.cpp b/src/library/sysadm-usermanager.cpp index af2f2f3..6bf7f3b 100644 --- a/src/library/sysadm-usermanager.cpp +++ b/src/library/sysadm-usermanager.cpp @@ -133,31 +133,21 @@ void UserManager::ChangeUserPassword(User user, QString newPassword) nfile.close(); } + //set the user password + QStringList args; + args.append(nfile.fileName()); //the temp file holding the password + args.append("|"); //which we're going to pipe to the stdin of if ( ! chroot.isEmpty() ) //if we're in a chroot { - //set the user password - QStringList args; - args.append(nfile.fileName()); //the temp file holding the password - args.append("|"); //which we're going to pipe to the stdin of args.append("chroot"); //a chroot args.append(chroot); //located here - args.append("pw usermod"); //where we're going to modify a user - args.append(user.UserName);//this user - args.append("-h"); //set the user's password - args.append("0"); //using stdin - General::RunCommand("cat",args); - } - else - { - QStringList args; - args.append(nfile.fileName()); //the temp file holding the password - args.append("|"); //which we're going to pipe to the stdin of - args.append("pw usermod"); //and we're going to modify the user account of - args.append(user.UserName); //this user - args.append("-h"); //and we're going to set their password - args.append("0"); //using stdin - General::RunCommand("cat",args); } + args.append("pw usermod"); //where we're going to modify a user + args.append(user.UserName);//this user + args.append("-h"); //set the user's password + args.append("0"); //using stdin + General::RunCommand("cat",args); + //remove the temp file holding the password nfile.remove();