Re: [autofs] latest autofs from centos 4

2008-09-16 Thread Ian Kent
On Tue, 2008-09-16 at 17:22 -0700, Joe Pruett wrote:
> it looks like some recent changes to both autofs v4 and v5 has caused the 
> siogcifconf buffer to be only 128 bytes.  this means that on our servers, 
> it can't correctly match a local address since that is only enough room 
> for 3 addresses and we're in the middle of a renumbering so we have 5-10 
> addresses per machine.  this was working fine until i just updated to 
> centos 4.7.  from looking at the code, it looks like someone created a 
> MAX_IF_BUF #define at 2048, but didn't use it for the ioctl call.  is that 
> a mistake?
> 
> i'll try a patched rpm locally and make sure this is the source of my 
> woes.

Yeah, known issue.
It's resolved in RHEL-5.3.

Not sure if this will apply to your package source but give it a try.

---
autofs-5.0.3 - fix interface config buffer size

From: Ian Kent <[EMAIL PROTECTED]>

When getting the interface configuration information autofs uses a
fixed size buffer for the interface information. If there are many
interfaces this causes the check to fail.
---

 modules/replicated.c |   51 ++
 1 files changed, 43 insertions(+), 8 deletions(-)


diff --git a/modules/replicated.c b/modules/replicated.c
index 362ab1b..ad1ede2 100644
--- a/modules/replicated.c
+++ b/modules/replicated.c
@@ -95,6 +95,41 @@ void seed_random(void)
return;
 }
 
+static int alloc_ifreq(struct ifconf *ifc, int sock)
+{
+   int ret, lastlen = 0, len = MAX_IFC_BUF;
+   char err_buf[MAX_ERR_BUF], *buf;
+
+   while (1) {
+   buf = malloc(len);
+   if (!buf) {
+   char *estr = strerror_r(errno, err_buf, MAX_ERR_BUF);
+   logerr("malloc: %s", estr);
+   return 0;
+   }
+
+   ifc->ifc_len = len;
+   ifc->ifc_req = (struct ifreq *) buf;
+
+   ret = ioctl(sock, SIOCGIFCONF, ifc);
+   if (ret == -1) {
+   char *estr = strerror_r(errno, err_buf, MAX_ERR_BUF);
+   logerr("ioctl: %s", estr);
+   free(buf);
+   return 0;
+   }
+
+   if (ifc->ifc_len == lastlen)
+   break;
+
+   lastlen = ifc->ifc_len;
+   len += MAX_IFC_BUF;
+   free(buf);
+   }
+
+   return 1;
+}
+
 static unsigned int get_proximity(const char *host_addr, int addr_len)
 {
struct sockaddr_in *msk_addr, *if_addr;
@@ -122,12 +157,7 @@ static unsigned int get_proximity(const char *host_addr, 
int addr_len)
fcntl(sock, F_SETFD, cl_flags);
}
 
-   ifc.ifc_len = sizeof(buf);
-   ifc.ifc_req = (struct ifreq *) buf;
-   ret = ioctl(sock, SIOCGIFCONF, &ifc);
-   if (ret == -1) {
-   char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
-   logerr("ioctl: %s", estr);
+   if (!alloc_ifreq(&ifc, sock)) {
close(sock);
return PROXIMITY_ERROR;
}
@@ -138,7 +168,7 @@ static unsigned int get_proximity(const char *host_addr, 
int addr_len)
i = 0;
ptr = (char *) &ifc.ifc_buf[0];
 
-   while (ptr < buf + ifc.ifc_len) {
+   while (ptr < (char *) ifc.ifc_req + ifc.ifc_len) {
ifr = (struct ifreq *) ptr;
 
switch (ifr->ifr_addr.sa_family) {
@@ -147,6 +177,7 @@ static unsigned int get_proximity(const char *host_addr, 
int addr_len)
ret = memcmp(&if_addr->sin_addr, hst_addr, addr_len);
if (!ret) {
close(sock);
+   free(ifc.ifc_req);
return PROXIMITY_LOCAL;
}
break;
@@ -162,7 +193,7 @@ static unsigned int get_proximity(const char *host_addr, 
int addr_len)
i = 0;
ptr = (char *) &ifc.ifc_buf[0];
 
-   while (ptr < buf + ifc.ifc_len) {
+   while (ptr < (char *) ifc.ifc_req + ifc.ifc_len) {
ifr = (struct ifreq *) ptr;
 
switch (ifr->ifr_addr.sa_family) {
@@ -178,6 +209,7 @@ static unsigned int get_proximity(const char *host_addr, 
int addr_len)
char *estr = strerror_r(errno, buf, 
MAX_ERR_BUF);
logerr("ioctl: %s", estr);
close(sock);
+   free(ifc.ifc_req);
return PROXIMITY_ERROR;
}
 
@@ -186,6 +218,7 @@ static unsigned int get_proximity(const char *host_addr, 
int addr_len)
 
if ((ia & mask) == (ha & mask)) {
close(sock);
+   free(ifc.ifc_req);
return PROXIMITY_SUBNET;
}
 
@@ -208,6 +241,7 @@ static unsigned int get_proximity(co

Re: [autofs] Execute script on expire.

2008-09-16 Thread Alexander
Thank you for response.
I simply forgot to CC the list. Now it should work.

This is a simplified situation of using automatic squashfs container
generation with autofs.
---

User: john.
autofs path to make squashfs: /makesqfs
access mask: /makesqfs//

autofs path to access sqfs: /usercontainers
access mask: /usercontainers//

John wants to put one of his folders (/home/john/foldertoprocess) in a
secure storage as a squashfs container which can be accessed
automatically anytime.

he could make it by isssuing regular command
mksquashfs   -
and copy resulted file to secure storage.

be he wants to use something simpler and robust.

Instead, John issues the following command:
cp /home/john/foldertoprocess /makesqfs/john/marketanalyzis

after some time he (and may be other users in the system) can access
his securely stored and read only files by following this symbolic
link
/containers/john/marketanalyzis


what happens on backend?
==

when he copies files to
/makesqfs/john/marketanalyzis
autofs executes a script that prepares temporary folder somewhere
(/tmp/john/marketanalyzis)
and mounts it as /makesqfs/john/marketanalyzis

when copying finishes and timeout of 5 minutes of inactivity fires in autofs,
it executes a designated script and passes /makesqfs/john/marketanalyzis
as a parameter.
script makes a squashfs container marketanalyzis.sfs and puts it
somewhere in secure location, and then makes a symbolic link at
/containers/john/marketanalyzis
which points to
/usercontainers/john/marketanalyzis

after script is done, autofs successfully unmounts
/makesqfs/john/marketanalyzis

Notes:
i think script can also remount /makesqfs/john/marketanalyzis as read
only before making actual mksquashfs command.
with such approach squashfs container creation may be done on separate
computer, while mounting part can also be done from different
locations.


2008/9/16 Jeff Moyer <[EMAIL PROTECTED]>:
> Alexander <[EMAIL PROTECTED]> writes:
>
>> truly speaking i don't know what is semantics with offset mounts, but
>> can describe following situation.
>>
>> client access the folder /tmpstorage/filestocompress
>> it mounts as /tmp/filestocompress (where /tmp is a tmpfs/shmfs or
>> unionfs with different underlying mount points)
>> client then copies his files there and after time of inactivity
>> autofs executes script /bin/compress and after it's completion
>> unmounts all corresponding mount points.
>
> I'm not quite sure I follow.  If you could list the steps, taking
> automount out of the picture, that would be helpful.  So, what is the
> ordered list of steps to perform, using *exact* path names.  Above,
> what's confusing me is that an access to /tmpstorage/filestocompress
> would mount anything on /tmp.  Autofs simply doesn't work that way.
>
>> the /bin/compress script does following:
>> 0. it gets parameter of what path is going to be unmounted, in our
>> example it is /tmp/filestocompress
>> 1. makes compressed tar, bzip, or squashfs container from
>> /tmp/filestocompress in /users/username/filestocompress.tar
>> 2. optionaly deletes all files in /tmp/filestocompress and exits
>>
>> something like that
>
> Again, a specific example would be more helpful (with real commands and
> paths).
>
> I'm curious to know why you didn't CC the list on your response.  Is it
> okay if we continue discussions there?
>
> Thanks!
>
> Jeff
>



-- 
Sincerely,
Alexandr N.

___
autofs mailing list
autofs@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/autofs


[autofs] latest autofs from centos 4

2008-09-16 Thread Joe Pruett
it looks like some recent changes to both autofs v4 and v5 has caused the 
siogcifconf buffer to be only 128 bytes.  this means that on our servers, 
it can't correctly match a local address since that is only enough room 
for 3 addresses and we're in the middle of a renumbering so we have 5-10 
addresses per machine.  this was working fine until i just updated to 
centos 4.7.  from looking at the code, it looks like someone created a 
MAX_IF_BUF #define at 2048, but didn't use it for the ioctl call.  is that 
a mistake?

i'll try a patched rpm locally and make sure this is the source of my 
woes.

___
autofs mailing list
autofs@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/autofs


Re: [autofs] Not correctly mount SMB shares ending in $

2008-09-16 Thread Ian Kent
On Sat, 2008-09-13 at 22:30 +1000, Matthew Jurgens wrote:
> Debug Log:
> 

snip ...

> Sep 16 01:03:13 tempgw automount[17954]: mounted /smb/xp0
> Sep 16 01:03:13 tempgw automount[17954]: do_mount: //xp0/C\
> $ /smb//smb/xp0/C$ type cifs options username=USER,password=PASSWORD
> using module generic
> Sep 16 01:03:13 tempgw automount[17954]: mount_mount: mount(generic):
> calling mkdir_path /smb/xp0/C$
> Sep 16 01:03:13 tempgw automount[17954]: mount_mount: mount(generic):
> calling mount -t cifs -s -o username=USER,password=PASSWORD //xp0/C\
> $ /smb/xp0/C$

This is the mount command we actually use.
We get rid of the quotes during the parsing of the entry but still the
backslash quote could be causing a problem. Do you agree or should I be
looking elsewhere?

> Sep 16 01:03:13 tempgw automount[17954]: mount(generic):
> mounted //xp0/C\$ type cifs on /smb/xp0/C$
> Sep 16 01:03:13 tempgw automount[17954]: send_ready: token = 345
> Sep 16 01:03:13 tempgw automount[17954]: mounted /smb/xp0/C$

Ian


___
autofs mailing list
autofs@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/autofs


Re: [autofs] Not correctly mount SMB shares ending in $

2008-09-16 Thread Ian Kent
On Tue, 2008-09-16 at 06:22 -0400, Jeff Layton wrote:
> On Tue, 16 Sep 2008 12:16:42 +0800
> Ian Kent <[EMAIL PROTECTED]> wrote:
> 
> > On Sat, 2008-09-13 at 12:03 +1000, Matthew Jurgens wrote:
> > > Ok, so I updated the script to the RPM version and added the
> > > authentication parts:
> > > 
> > > #!/bin/bash
> > > 
> > > # This file must be executable to work! chmod 755!
> > > key="$1" # key comes is as something like a hostname eg matthew
> > > opts="-fstype=cifs,username=$SMB_USER,password=$SMB_PASSWORD"
> > > 
> > > smbauthfile=/tmp/smbauth.tmp
> > > cat << EOT > $smbauthfile
> > > username=$SMB_USER
> > > password=$SMB_PASSWORD
> > > EOT
> > > 
> > > 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
> > > 
> > > $SMBCLIENT -A $smbauthfile -gL $key 2>/dev/null| awk -v key="$key" -v
> > > opts="$opts" -F'|' -- '
> > > BEGIN   { ORS=""; first=1 }
> > > /Disk/  {
> > >   if (first)
> > > print opts; first=0
> > >   dir = $2
> > >   loc = $2
> > >   # Enclose mount dir and location in quotes
> > >   # Double quote "$" in location as it is special
> > >   gsub(/\$$/, "\\$", loc);
> > >   print " \\\n\t \"/" dir "\"", "\"://" key "/" loc
> > > "\""
> > > }
> > > END { if (!first) print "\n"; else exit 1 }
> > > '
> > > 
> > > 
> > > 
> > > Now its output is slightly different but the result is still the same
> > > -fstype=cifs,username=USER,password=PASSWORD \
> > >  "/C" "://xp0/C" \
> > >  "/ADMIN$" "://xp0/ADMIN\$" \
> > >  "/C$" "://xp0/C\$"
> > > 
> > > vs the older output
> > > -fstype=cifs,username=USER,password=PASSWORD \
> > >  /C "://xp0/C" \
> > >  /ADMIN\$ "://xp0/ADMIN\$" \
> > >  /C\$ "://xp0/C\$"
> > > mount:
> > > //xp0/C/$ on /smb/xp0/C$ type cifs (rw,mand)
> > 
> > As I said before, the mount command looks OK, but I wonder if any recent
> > CIFS kernel changes are getting confused by the "\" in the location
> > (aka //xp0/C\$). That would be a bit of a bummer as autofs needs it but
> > getting rid of it before the actual mount isn't straight forward.
> > 
> 
> Yes. There are some recent changes to the mount.cifs command and CIFS
> VFS in kernel to try to handle delimiters a little more intelligently
> (they were really broken before in some cases). This mount command does
> not look right to me though. You have this:
> 
> "://xp0/C\$"
> 
> ...and the mount helper is interpreting that last \ as a delimiter.
> Since you have that in quotes already, you shouldn't need to escape the
> trailing $. So I think this would be more likely to work:

As with all things it's not quite that simple.

The "$" needs to be doubly escaped because it's also indicates a 
possible macro definition in a map entry.

> 
> "://xp0/C$"
> 
> Cheers,

___
autofs mailing list
autofs@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/autofs


Re: [autofs] Not correctly mount SMB shares ending in $

2008-09-16 Thread Jeff Layton
On Tue, 16 Sep 2008 12:16:42 +0800
Ian Kent <[EMAIL PROTECTED]> wrote:

> On Sat, 2008-09-13 at 12:03 +1000, Matthew Jurgens wrote:
> > Ok, so I updated the script to the RPM version and added the
> > authentication parts:
> > 
> > #!/bin/bash
> > 
> > # This file must be executable to work! chmod 755!
> > key="$1" # key comes is as something like a hostname eg matthew
> > opts="-fstype=cifs,username=$SMB_USER,password=$SMB_PASSWORD"
> > 
> > smbauthfile=/tmp/smbauth.tmp
> > cat << EOT > $smbauthfile
> > username=$SMB_USER
> > password=$SMB_PASSWORD
> > EOT
> > 
> > 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
> > 
> > $SMBCLIENT -A $smbauthfile -gL $key 2>/dev/null| awk -v key="$key" -v
> > opts="$opts" -F'|' -- '
> > BEGIN   { ORS=""; first=1 }
> > /Disk/  {
> >   if (first)
> > print opts; first=0
> >   dir = $2
> >   loc = $2
> >   # Enclose mount dir and location in quotes
> >   # Double quote "$" in location as it is special
> >   gsub(/\$$/, "\\$", loc);
> >   print " \\\n\t \"/" dir "\"", "\"://" key "/" loc
> > "\""
> > }
> > END { if (!first) print "\n"; else exit 1 }
> > '
> > 
> > 
> > 
> > Now its output is slightly different but the result is still the same
> > -fstype=cifs,username=USER,password=PASSWORD \
> >  "/C" "://xp0/C" \
> >  "/ADMIN$" "://xp0/ADMIN\$" \
> >  "/C$" "://xp0/C\$"
> > 
> > vs the older output
> > -fstype=cifs,username=USER,password=PASSWORD \
> >  /C "://xp0/C" \
> >  /ADMIN\$ "://xp0/ADMIN\$" \
> >  /C\$ "://xp0/C\$"
> > mount:
> > //xp0/C/$ on /smb/xp0/C$ type cifs (rw,mand)
> 
> As I said before, the mount command looks OK, but I wonder if any recent
> CIFS kernel changes are getting confused by the "\" in the location
> (aka //xp0/C\$). That would be a bit of a bummer as autofs needs it but
> getting rid of it before the actual mount isn't straight forward.
> 

Yes. There are some recent changes to the mount.cifs command and CIFS
VFS in kernel to try to handle delimiters a little more intelligently
(they were really broken before in some cases). This mount command does
not look right to me though. You have this:

"://xp0/C\$"

...and the mount helper is interpreting that last \ as a delimiter.
Since you have that in quotes already, you shouldn't need to escape the
trailing $. So I think this would be more likely to work:

"://xp0/C$"

Cheers,
-- 
Jeff Layton <[EMAIL PROTECTED]>

___
autofs mailing list
autofs@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/autofs