Mailinglist Archive: opensuse (686 mails)

< Previous Next >
[opensuse] Re: shell script help
Felix Miata wrote:
While all this may well enough explain why -f2, I don't see any response to my hostname question precipitated by your prior response.

If you log in remotely, PAM will set the host you log in from on first
contact to the system in PAM_RHOST during authentication.

This is usually used in /etc/security/pam_env.conf, to set the env
once per-contact session with the system -- usually 'REMOTEHOST' to where
you came from and DISPLAY would get ${$REMOTEHOST:X-server.screen}.


Recently, in 11.3, I believe, SuSE broke this by redefining session to
anytime you change seats. So they run PAM_ENV on each new seat change --
zeroing out your REMOTEHOST and DISPLAY -- making them worthless.

I tried to have it fixed, but the maintainer on pam knows he wants pam_env
to set the env for each seat-session -- thus making the documented usage
of the file worthless in the default suse configuration.

If you log in with 'ssh', and it is tunnelling your 'X' session, it will
setup a socket thatw ill set DISPLAY to localhost:tunnelid. However, if you
are on a local network you DON'T want that. It slows down X and raises
latency by a noticeable amount even on a 1Gb network. The difference on
faster networks is proportionately worse, since ssh encryption will knock
off a sizeable percentage. But if you are going over the internet/
insecure lines... you run risks of password sniffing if you aren't careful
(could use certs to login)...

I use the presence or absence of REMOTEHOST to change my prompt --
If I am logged in remotely, I display the host I am logged into, else not.

BTW, if you want the numeric field (which could be 0.0 or 1.0, not just
0 or 1), you can do it in bash-only without cut:
${DISPLAY#*:}
"#" pounds down the beginning of a the contents of a var,
while % is a modulus type operator in many languages, and I think
of it cutting off the tail of the contents of a var...

So ${VARNAME#<expression to match the front you want to pound off -- in this
case
a hostname:, so I used *:. If I wanted to truncate the tail and just get the
hostname part, I'd use
${VARNAME%:<expression to match anything after ':'> or a '*' for DISPLAY...
Note ## and %% will use the longest match that will fit your specification,
while # and % will use the shortest:

if A=/usr/local/bin/foobar, then ${A%/*} = /usr/local/bin && ${A%%/*} = /usr
${A#*/} = usr/local/bin/foobar (cuz */ matches the empty string and 1st slash)
while ${##*/} = foobar (take off everything including the last '/').

BASH also has substitution:
a="one two three four"
echo ${a/ /,} = "one,two three four" &&
echo ${a// /,}= "one,two,three,four" (the double // does all of them).

cut will work, but if you can remember the #(pound)off the front, and %truncate or chop
off the back that solves alot of tiddly problems.





--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >