Thursday August 27, 2009 Someone has posted a script to start a remote xterm on BigAdmin which exposes a number of issues I thought it would be better if google stood some chance of finding a better answer or at least an answer that does not rely on inherently insecure settings.
Remote X applications should be started using ssh -X so that the X traffic is encrypted and if you add -C compressed which can be a significant performance boost. So a script to do this could be handy although to be honest knowing the ssh options or having them set as the default in your .ssh/config is just as easy:
: exdev.eu FSS 31 $; egrep '^(Compress|ForwardX)' ~/.ssh/config ForwardX11 yes Compression yes : exdev.eu FSS 32 $; ssh -f pearson /usr/X11/bin/xterm : exdev.eu FSS 33 $;
or more usefully to start graphical tools:
: exdev.eu FSS 33 $; ssh -f pearson pfexec /usr/sadm/admin/bin/dhcpmgr : exdev.eu FSS 34 $;
However if you really want a script to do it here is one that will and no need to mess with your .ssh/config
#!/bin/ksh
REMOTE_PATH=${REMOTE_PATH:-${PATH}}
APP=${0##*/}
if (( $# < 1 ))
then
print "USAGE: ${APP} host [args]" >&2
exit 1
fi
host=$1
shift
exec /usr/bin/ssh -o ClearAllForwardings=yes -C -Xfn $host \
PATH=${REMOTE_PATH} pfexec ${APP#r} $@If you save this into a file called “rxterm” then running “rxterm remotehost” will start an xterm on the system remotehost assuming you can ssh to that system.
More entertainingly you can save it as “rdhcpmgr” and it will start the dhcpmgr program on a remote system and securely display it on your current display (assuming your PATH includes /usr/sadm/admin/bin and your profile allows you access to that application). You can use it to start any application by simple naming it after the application in question with a preceding “r”.
Sunday April 05, 2009 I had reason to discover if my solution for backing up the windows PC worked. Apparently the PC had not been working properly for a while but no one had mentioned that to me. The symptoms were:
No menu bar at the bottom of the screen. It was almost like the screen was the wrong size but how it was changed is/was a mystery.
It was claiming it needed to revalidate itself as the hardware had changed, which it catagorically had not and I had 2 days to sort it out. Apparenty this message had been around for a few days (weeks?) but was ignored.
Now I'm sure I could have had endless fun reading forums to find out how to fix these things but it was Saturday night nd I was going cycling in the morning. So time to boot solaris and restore the back up. First I took a back up of what was on the disk, just in case I get a desire to relive the issue. I just needed one script to restore it over ssh. The script is:
: pearson FSS 14 $; cat /usr/local/sbin/xp_restore #!/bin/ksh exec dd of=/dev/rdsk/c0d0p1 bs=1k : pearson FSS 15 $;
and the command was:
$ ssh pc pfexec /usr/local/sbin/xp_restore < backup.dd
having chosen the desired snapshot. Obviously the command was added to /etc/security/exec_attr. Then just leave that running over night. In the morning the system booted up just fine, complained about the virus definitions being out of date and various things needing updates but all working. Alas doing this before I went cycling made me late enough to miss the peleton, if it was there.
Thursday December 15, 2005 Darren has just posted his fast bringover script that solves some of my desire to be able to have a file system per workspace. I'm not commenting on the script since it manages to trip one of my shell script peeves that of calling a program and then calling exit $?. What is wrong with exec? I'll keep taking the tablets.
However it does not solve my wanting to be able to let users be able to create their own ZFS file systems below a file system that they own.
Like I said in the email this can mostly be done via an RBAC script, well here it is:
#!/bin/ksh -p
PATH=/usr/bin:/usr/sbin
if [ "$_" != "/usr/bin/pfexec" -a -x /usr/bin/pfexec ]; then
exec /usr/bin/pfexec $0 $@
fi
function get_owner
{
echo $(ls -dln ${PARENT} | nawk '{ print $3 }')
}
function create_file_system
{
typeset mpt name
zfs list -H -t filesystem -o mountpoint,name,quota | \
while read mpt name quota
do
if [[ $mpt == $PARENT ]]
then
zfs create ${DIR#/} && chown $uid $DIR && \
zfs set quota=${quota} ${DIR#/}
exit $?
fi
done
echo no zfs file system $PARENT >&2
exit 1
}
function check_quota
{
typeset -i count
typeset mpt name
count=0
zfs list -H -t filesystem -o mountpoint,name | while read mpt name
do
if [[ $(get_owner $name) == $uid ]]
then
let count=count+1
fi
done
echo $count
}
MAX_FILE_SYSTEMS_PER_USER=10
test -f /etc/default/zfs_user_create && . /etc/default/zfs_user_create
if [[ $# -ne 1 ]]
then
echo "Usage: $1 filesystem" >&2
exit 1
fi
DIR=$1
PARENT=${1%/*}
if ! [[ -d $PARENT ]]
then
echo "$0: Failed to make directory \"$1\"; No such file or directory" >&2
exit 1
fi
uid=$(id | sed -e s/uid=// -e 's/(.*//')
owner=$(get_owner $1)
if [[ $uid != $owner ]]
then
echo "$0: $1 not owner" >&2
exit 1
fi
if [[ $(check_quota) -gt ${MAX_FILE_SYSTEMS_PER_USER} ]]
then
echo "too many file systems"
exit 1
fi
create_file_system
It has a hack in it to limit the number of file systems that a user can create just to stop them being silly. Then you just need the line in /etc/security/exec_attr:
All:suser:cmd:::/usr/local/share/sh/zfs_create:euid=0
Now any user can create a file system under a file system they already own. The file systems don't share a single quota which would be nice but for my purposes this will do.
Next trick to let them destroy them and take snapshots of them. The snapshots being the real reason I want all of this.
Tags: Solaris OpenSolaris ZFS shell script
Saturday July 02, 2005 Fed up with the bourne shell for root? All the power of root but with a proper shell, not csh, a proper shell! You can add a role with the korn shell or any other shell and then assign that role to the users you wish to be able to access it. They still have to type the password of the role but they get a sensible shell when they get it right, plus others don't even get the option.
Here is how. For the a korn shell “root” account:
# roleadd -d /root -P "Primary Administrator" -s /usr/bin/pfksh kroot # usermod -R root,kroot me # passwd kroot New Password: Re-enter new Password: passwd: password successfully changed for kroot #
Now I have a role, kroot, to which only I can su(1M) and it has a decent shell. I can still use the root role if I want pain and I have not changed root's shell which is probably a good thing. Make sure /root already exists, it did for me as it is root's home directory already.
Tags: Solaris ksh csh rbac roles
Except where otherwise noted, this site is
licensed under a Creative Commons License 2.0
This is a personal weblog, I do not speak for my employer.