* user token
@ 2007-11-26 9:49 muzzol
2007-11-26 18:23 ` Ian Kent
0 siblings, 1 reply; 10+ messages in thread
From: muzzol @ 2007-11-26 9:49 UTC (permalink / raw)
To: autofs
hi!
is any token related to user trying to mount passed to autofs?
i've tried $USER and other variables without any success.
what i want to do is something like:
============================================
#!/bin/bash
# $Id: auto.smb,v 1.3 2005/04/05 13:02:09 raven Exp $
# This file must be executable to work! chmod 755!
key="$1"
mountopts="-fstype=cifs"
smbopts=""
credfile="/home/$USER/auto.smb.$key"
for P in /bin /sbin /usr/bin /usr/sbin
do
if [ -x $P/smbclient ]
then
SMBCLIENT=$P/smbclient
break
fi
done
[ -x $SMBCLIENT ] || exit 1
if [ -e $credfile ]; then
mountopts="$mountopts,credentials=$credfile"
smbopts="-A $credfile"
else
smbopts="-N"
fi
$SMBCLIENT $smbopts -gL $key 2>/dev/null| awk -v key="$key" -v
opts="$mountopts" -F'|' -- '
BEGIN { ORS=""; first=1 }
/Disk/ { if (first) { print opts; first=0 }; sub(/ /, "\\ ",
$2); print " \\\n\t /" $2, "://" key "/" $2 }
END { if (!first) print "\n"; else exit 1 }
'
============================================
note the credfile line:
credfile="/home/$USER/auto.smb.$key"
if there's no variable, can any additional parameter be passwd to the
executables mappings beside the key?
regards,
muzzol
--
========================
^ ^
O O
(_ _)
muzzol(a)gmail.com
========================
jabber id: muzzol(a)jabber.dk
========================
No atribueixis qualitats humanes als ordinadors.
No els hi agrada.
========================
"El gobierno español sólo habla con terroristas, homosexuales y
catalanes, a ver cuando se decide a hablar con gente normal"
Jiménez Losantos
========================
<echelon spamming>
bomb terrorism bush aznar teletubbies
</echelon spamming>
_______________________________________________
autofs mailing list
autofs@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/autofs
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: user token
2007-11-26 9:49 user token muzzol
@ 2007-11-26 18:23 ` Ian Kent
2007-11-26 19:27 ` muzzol
0 siblings, 1 reply; 10+ messages in thread
From: Ian Kent @ 2007-11-26 18:23 UTC (permalink / raw)
To: muzzol; +Cc: autofs
On Mon, 2007-11-26 at 10:49 +0100, muzzol wrote:
> hi!
>
> is any token related to user trying to mount passed to autofs?
>
> i've tried $USER and other variables without any success.
So you're not using version 5 then, or are you?
Version 5 sets several variables in the environment, USER, GROUP, HOME,
UID and GID.
>
> what i want to do is something like:
>
> ============================================
>
> #!/bin/bash
>
> # $Id: auto.smb,v 1.3 2005/04/05 13:02:09 raven Exp $
>
> # This file must be executable to work! chmod 755!
>
> key="$1"
> mountopts="-fstype=cifs"
> smbopts=""
> credfile="/home/$USER/auto.smb.$key"
>
> for P in /bin /sbin /usr/bin /usr/sbin
> do
> if [ -x $P/smbclient ]
> then
> SMBCLIENT=$P/smbclient
> break
> fi
> done
>
> [ -x $SMBCLIENT ] || exit 1
>
> if [ -e $credfile ]; then
> mountopts="$mountopts,credentials=$credfile"
> smbopts="-A $credfile"
> else
> smbopts="-N"
> fi
>
> $SMBCLIENT $smbopts -gL $key 2>/dev/null| awk -v key="$key" -v
> opts="$mountopts" -F'|' -- '
> BEGIN { ORS=""; first=1 }
> /Disk/ { if (first) { print opts; first=0 }; sub(/ /, "\\ ",
> $2); print " \\\n\t /" $2, "://" key "/" $2 }
> END { if (!first) print "\n"; else exit 1 }
> '
>
> ============================================
>
> note the credfile line:
>
> credfile="/home/$USER/auto.smb.$key"
>
> if there's no variable, can any additional parameter be passwd to the
> executables mappings beside the key?
No other parameters can be passed to program maps.
I don't really know of a sane way to do this.
Ian
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: user token
2007-11-26 18:23 ` Ian Kent
@ 2007-11-26 19:27 ` muzzol
2007-11-27 2:17 ` Ian Kent
0 siblings, 1 reply; 10+ messages in thread
From: muzzol @ 2007-11-26 19:27 UTC (permalink / raw)
To: Ian Kent; +Cc: autofs
En/na Ian Kent ha escrit:
> On Mon, 2007-11-26 at 10:49 +0100, muzzol wrote:
> No other parameters can be passed to program maps.
> I don't really know of a sane way to do this.
>
is this by design?
do you plan to add such feature in the future?
--
========================
^ ^
O O
(_ _)
muzzol(a)muzzol.com
========================
jabber id: muzzol(a)jabber.dk
========================
No atribueixis qualitats humanes als ordinadors.
No els hi agrada.
========================
"El gobierno español sólo habla con terroristas, homosexuales y
catalanes, a ver cuando se decide a hablar con gente normal"
Jiménez Losantos
========================
<echelon spamming>
bomb terrorism bush aznar teletubbies
</echelon spamming>
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: user token
2007-11-26 19:27 ` muzzol
@ 2007-11-27 2:17 ` Ian Kent
2007-11-27 8:19 ` muzzol
[not found] ` <4a3f02760711270019v490249fet119d1683cd41f995@mail.gmail.com>
0 siblings, 2 replies; 10+ messages in thread
From: Ian Kent @ 2007-11-27 2:17 UTC (permalink / raw)
To: muzzol; +Cc: autofs
On Mon, 2007-11-26 at 20:27 +0100, muzzol wrote:
> En/na Ian Kent ha escrit:
> > On Mon, 2007-11-26 at 10:49 +0100, muzzol wrote:
> > No other parameters can be passed to program maps.
> > I don't really know of a sane way to do this.
> >
>
> is this by design?
It's been that way since before I took over maintenance of autofs.
>
> do you plan to add such feature in the future?
Like I said, I don't see any "sane" way to do this.
There is a way to use an external environment variable withing maps but
I haven't looked at that code for some time now.
What is it that you need that the standard environment I mentioned
doesn't provide?
Ian
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: user token
2007-11-27 2:17 ` Ian Kent
@ 2007-11-27 8:19 ` muzzol
2007-11-28 16:49 ` Stef Bon
[not found] ` <4a3f02760711270019v490249fet119d1683cd41f995@mail.gmail.com>
1 sibling, 1 reply; 10+ messages in thread
From: muzzol @ 2007-11-27 8:19 UTC (permalink / raw)
To: Ian Kent; +Cc: autofs
2007/11/27, Ian Kent <raven@themaw.net>:
> What is it that you need that the standard environment I mentioned
> doesn't provide?
>
for example sending a message to user with zenity. for identifying
wich user is performing the request i must do some tricky things now,
and only works on stations with just one user logged in.
exposing some user variables _inside_ executable mappings would help a
lot with mounts that need some interaction from user.
look out this pseudo-code:
if user request for samba mount
if not exists credentials file
ask for credentials
as i said, i got a working script, but is very dirty and specific.
--
========================
^ ^
O O
(_ _)
muzzol(a)gmail.com
========================
jabber id: muzzol(a)jabber.dk
========================
No atribueixis qualitats humanes als ordinadors.
No els hi agrada.
========================
"El gobierno español sólo habla con terroristas, homosexuales y
catalanes, a ver cuando se decide a hablar con gente normal"
Jiménez Losantos
========================
<echelon spamming>
bomb terrorism bush aznar teletubbies
</echelon spamming>
_______________________________________________
autofs mailing list
autofs@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/autofs
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: user token
2007-11-27 8:19 ` muzzol
@ 2007-11-28 16:49 ` Stef Bon
0 siblings, 0 replies; 10+ messages in thread
From: Stef Bon @ 2007-11-28 16:49 UTC (permalink / raw)
To: autofs
On Tuesday 27 November 2007 09:19:35 muzzol wrote:
> 2007/11/27, Ian Kent <raven@themaw.net>:
> > What is it that you need that the standard environment I mentioned
> > doesn't provide?
> >
>
> for example sending a message to user with zenity. for identifying
> wich user is performing the request i must do some tricky things now,
> and only works on stations with just one user logged in.
>
> exposing some user variables _inside_ executable mappings would help a
> lot with mounts that need some interaction from user.
>
> look out this pseudo-code:
>
> if user request for samba mount
> if not exists credentials file
> ask for credentials
>
> as i said, i got a working script, but is very dirty and specific.
>
>
Well i've done something like this. Look at:
http://www.howtoforge.com/automatic_discovery_mounting_smb_networkshares
I've been struggling with this question some time, and found a good way to deal with this USER
variable.
In short:
. there are some scripts which are run by fcron which maintain a cache. These scripts make use of nbtscan (systemwide) and
smbclient (per user) to find all hosts and shares. The latest make use of a credentialsfile (if found, if no then guest).
. one of the mainthings these script create is a "windows network tree" in the homemap of all users logged in:
~/Global Network/Windows Network/Host A/first share A
second share A
Host B/first share B
second share B
The shares are symbolic links. For example the first share A of host A points to:
/mnt/autofs/user/%USER%/smb/Host A/first share A
Now on this directory my automount program is active (which for this user is started
when he logs in, but still is running as root), with only:
auto.hosts and auto.share which look like:
auto.hosts in the /var/run/autofs/user/%USER%/smb directory
#!/bin/bash
echo "-fstype=autofs,-Dhost=${host} file:/var/run/autofs/user/%USER%/smb/auto.share"
and auto.share also in the /var/run/autofs/user/%USER%/smb directory
* ${host}:/&
* -fstype=smb ://${host}/&
Now this smb filesystem does not exist (only cifs and smbfs right?) I've created a script
mount.smb which calls mount.cifs (or mount.smbfs).
To this program no variable is know which can identify the user. Simular to your problem.
Now when you look at the mountpoint, the mountpoint is always something like:
/mnt/autofs/user/%USER%/smb/somehost/someshare
so with a program like cut you can extract the exact userid:
userid=$(echo $mountpoint | cut --delimiter "/" --fields 5 )
If this is found,
you can check in the userhomedirectory for a credentialsfile.
If found, the script will call the right mountprogram (mount.cifs or mount.smbfs)
with the credentialsfile. If not there, it will do a guest mount.
Note that this construction in my mail here is newer than in the howto on howtoforge.
I'm running this at home, and it's very good.
Hope this helps,
Stef Bon
Voorburg
the Netherlands
^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <4a3f02760711270019v490249fet119d1683cd41f995@mail.gmail.com>]
end of thread, other threads:[~2007-12-13 8:08 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-26 9:49 user token muzzol
2007-11-26 18:23 ` Ian Kent
2007-11-26 19:27 ` muzzol
2007-11-27 2:17 ` Ian Kent
2007-11-27 8:19 ` muzzol
2007-11-28 16:49 ` Stef Bon
[not found] ` <4a3f02760711270019v490249fet119d1683cd41f995@mail.gmail.com>
[not found] ` <1196168788.3973.33.camel@raven.themaw.net>
2007-11-27 15:13 ` muzzol
2007-11-27 15:40 ` Ian Kent
[not found] ` <4a3f02760711280919t6262161cvf46336a8ac018e3e@mail.gmail.com>
[not found] ` <1196343240.3217.45.camel@raven.themaw.net>
[not found] ` <4a3f02760711290612g25d4bd8fvd0ada6c893998ef3@mail.gmail.com>
2007-11-29 14:13 ` muzzol
2007-12-13 8:08 ` muzzol
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.