Welcome |
---|
Welcome to refracta You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today! |
# Change/create root password
change_root_pass () {
newpass=$(yad --form --field "Password:H" --field "Retype Password:H" --separator="@_@" --title "Password" --image="dialog-password" --button=OK:0 --button=Cancel:1)
if [[ $? = 1 ]] ; then
return
fi
if [ $(echo $newpass | awk -F"@_@" '{print $1}') != $(echo $newpass | awk -F"@_@" '{print $2}') ] ; then
try_again_1
return
else
# Redirect stderr to keep the output of the passwd command.
exec 2>&1
echo $newpass | sed 's/@_@/\n/g' | chroot /target passwd
# Resume logging errors in file
exec 2>>"$error_log"
fi
}
try_again_1 () {
yad --image="gtk-dialog-warning" --title "Error" --button=Yes:0 --button=No:1 \
--text "Entries do not match. Do you want to try again?\n(If you say No, password will not be changed.)"
if [[ $? = 0 ]] ; then
change_root_pass
fi
}
yad --title="Change Root password" --button=Yes:0 --button=No:1 \
--text="Would you like to change the Root password?
This is highly Recommended. "
if [[ $? = 0 ]]; then
change_root_pass
fi
# Change user password
change_user_pass () {
newpass=$(yad --form --field "Password:H" --field "Retype Password:H" --separator="@_@" --title "Password" --image="dialog-password" --button=OK:0 --button=Cancel:1)
if [[ $? = 1 ]] ; then
return
fi
if [ $(echo $newpass | awk -F"@_@" '{print $1}') != $(echo $newpass | awk -F"@_@" '{print $2}') ] ; then
try_again_1
return
else
# Redirect stderr to keep the output of the passwd command.
exec 2>&1
echo $newpass | sed 's/@_@/\n/g' | chroot /target passwd "$newname"
# Resume logging errors in file
exec 2>>"$error_log"
fi
}
try_again_1 () {
yad --image="gtk-dialog-warning" --title "Error" --button=Yes:0 --button=No:1 \
--text "Entries do not match. Do you want to try again?\n(If you say No, password will not be changed.)"
if [[ $? = 0 ]] ; then
change_user_pass
fi
}
yad --title="Change user password" --button=Yes:0 --button=No:1 \
--text="Would you like to change the user's password?
This is highly Recommended. "
if [[ $? = 0 ]]; then
change_user_pass
fi
Users browsing this forum: No registered users and 0 guests