Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
re-entering pw for su xterm [solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
nordic bro
Guru
Guru


Joined: 25 Oct 2003
Posts: 582

PostPosted: Sun Jun 15, 2014 9:16 pm    Post subject: re-entering pw for su xterm [solved] Reply with quote

I use this to start a root xterm (csh if it matters):

/usr/bin/xterm ... -e su -

that's in "Exec=" for a .desktop file so I can click an icon to start it.

the xterm pops up with "Password:" but the problem is if I enter the pw wrong it closes and I have to keep clicking my icon/entering pw over and over until I enter it correctly (root pw is complex, I don't know touch-typing so pw is prone to being mistyped).

what I'd like was if there was a way to get the "Password:" prompt to continue asking until it gets the correct one instead of closing xterm after one bad try - is there a way to do that? like some su/xterm env var I can set? man pages for either don't indicate anything, maybe this is some system-wide thing I need to set? I have "LOGIN_RETRIES 5" in /etc/login.defs but that doesn't seem to matter here.

or maybe a single try is part of su security? if so is there a way using something like x11-ssh-askpass to do what I want? I have a script for mounting encfs partitions with a pw loop doing just that but when I tried to adapt that to my root xterm prob it seems as if the xterm won't accept pw being sent to it (i.e., it's only interested in kb input?).


Last edited by nordic bro on Thu Jun 19, 2014 2:30 am; edited 1 time in total
Back to top
View user's profile Send private message
russK
l33t
l33t


Joined: 27 Jun 2006
Posts: 618

PostPosted: Mon Jun 16, 2014 3:10 am    Post subject: Reply with quote

su returns 1 on authentication failure, so you could create a script to retry several times like this:

mysu.sh
Code:

#!/bin/bash

x=$((0))
rval=1
while [ $x -lt 5 -a $rval -eq 1 ]
do
    su -
    rval=$?
    x=$((x+1))
done


Then make your .desktop file refer to this script

HTH
Back to top
View user's profile Send private message
nordic bro
Guru
Guru


Joined: 25 Oct 2003
Posts: 582

PostPosted: Thu Jun 19, 2014 2:30 am    Post subject: Reply with quote

works like a charm, thanks so much!! it's such a relief not having this annoying 'click icon/failed pw, click icon/failed pw ...' anymore. :D
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Thu Jun 19, 2014 12:16 pm    Post subject: Reply with quote

nordic bro ... while russK's script is perfectly fine, if there is a (while/until) loop the return value is evaluated so you can loop eternally until success ...

Code:
#!/bin/sh

until su --login ; do
    :
done

best ... khay
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum