Koozali.org: home of the SME Server

Changing users directory location

aux2006

Changing users directory location
« on: June 21, 2007, 02:06:52 PM »
Hi there,

how do i change the users directory location, location different from SME defaults?

what i want is for example is to put all the users folder in one the ibays so that it can be accessible from anyone who has right to the ibay or from the net.

thank you!
aux

Offline mmccarn

  • *
  • 2,651
  • +10/-0
Changing users directory location
« Reply #1 on: June 21, 2007, 02:58:36 PM »
You should be able to do this by using appropriate group permissions and hard-links, something like this:

usermaster -> /home/e-smith/files/ibays/usermaster

usera -> /home/e-smith/files/users/usera -> /home/e-smith/files/ibays/usermaster/files/usera

userb -> /home/e-smith/files/users/userb -> /home/e-smith/files/ibays/usermaster/files/userb

First, create the ibay and the 2 users, then do something like this:
Code: [Select]
rm -f /home/e-smith/files/users/usera
rm -f /home/e-smith/files/users/userb
mkdir /home/e-smith/files/ibays/usermaster/html/usera
mkdir /home/e-smith/files/ibays/usermaster/html/userb
ln -s /home/e-smith/files/ibays/usermaster/html/usera /home/e-smith/files/users/usera
ln -s /home/e-smith/files/ibays/usermaster/html/userb /home/e-smith/files/users/userb
db accounts setprop usermaster FollowSymLinks enabled
signal-event ibay-modify usermaster
/etc/init.d/httpd graceful


If the ibay and the users all belong to the same group then they will be able to access everything at http://<servername>/usermaster.

However, *none* of the users will be able to access their files directly (using http://<uservername>/usera, for example).  See http://forums.contribs.org/index.php?topic=37412.0

It might work better to reverse the process, leaving the user folders in their normal location and putting symlinks in the ibay:
Code: [Select]
ln -s /home/e-smith/files/users/usera /home/e-smith/files/ibays/usermaster/html/usera
ln -s /home/e-smith/files/users/userb /home/e-smith/files/ibays/usermaster/html/userb
db accounts setprop usermaster FollowSymLinks enabled
signal-event ibay-modify usermaster


You still need to set group permissions cleverly to get everything working.

I'm not sure you need to do either of these, though - if you set the group permissions so that either of these schemes will work then your users should be able to access everything anyway...

aux2006

Changing users directory location
« Reply #2 on: June 21, 2007, 05:56:21 PM »
mmccarn,

thank you!

i made some progress with this and it is working fine.

i followed this suggestion of yours
Quote
Code: [Select]
ln -s /home/e-smith/files/users/usera /home/e-smith/files/ibays/usermaster/html/usera
ln -s /home/e-smith/files/users/userb /home/e-smith/files/ibays/usermaster/html/userb
db accounts setprop usermaster FollowSymLinks enabled
signal-event ibay-modify usermaster


but to give access to the group i changed usera and userb's group file permission to certain group that must have access to the files of usera and userb.

thus usera and userb dir listing looks like this
Code: [Select]
drwxrwx---  5 usera      managers 4096 Jun 21 16:23 usera
drwxrwx---  5 usera      managers 4096 Jun 21 16:25 userb


how i wish i have this option to change the user's folder location upon creating the account to be located anywhere i like, with group permission set. (like what we can do with webmin). or I hope SME can do better by having user templates. that i can create a structure like this.

Code: [Select]
/home/e-smith/files/users/group1/user1
/home/e-smith/files/users/group1/user2
...
/home/e-smith/files/users/group2/user3
/home/e-smith/files/users/group2/user4
...


or has anyone able to do this?

thank you,
aux

Offline mmccarn

  • *
  • 2,651
  • +10/-0
Changing users directory location
« Reply #3 on: June 22, 2007, 05:33:23 AM »
It looks as though (I'm going way out on a limb here...) you could do what you want by customizing /etc/e-smith/events/actions/user-create-unix.

Find and modify the lines controlling directory creation and access rights.

You could create a custom variable named 'Ibay', define it for each user with db accounts setprop usera Ibay group1, then add a bit to /etc/e-smith/events/actions/user-create-unix that creates the appropriate symlink:
Code: [Select]
my $ibay = $acct->prop('Ibay') || '';
system(
    "/bin/ln",
    "-s", "/home/e-smith/files/users/$userName",
    "/home/e-smith/files/ibays/$ibay/html/$userName"
    ) == 0 or die "Failed to create symlink in $ibay for $userName.\n"


warning: I just copied & adapted this chunk from S04user-create-unix; I don't understand what it does, and really suspect there should be some sort of conditional to make it do nothing if $ibay is empty...

Also, /etc/e-smith/events/actions/user-create-unix is not a templated file -- so it is likely to be replaced, and may be modified in unexpected ways, whenever you update your SME system; maybe you should copy /etc/e-smith/events/actions/user-create-unix to another file, customize it to *just* make the changes we're talking about, then add a link to it to the /home/e-smith/events/user-create and /home/e-smith/events/user-modify.

(The more I type, the more I think you'll want to sign on as a developer before you're done with this project...)

Or, you could go the other way and modify the ibay-create scripts to scan for all users assigned to a given ibay and create the symlinks there.

Here's a post about installing an rpm that handles ACL file rights - I think a bit more like Windows than the linux default.  I don't know how well (or if) it works: http://forums.contribs.org/index.php?topic=36092.0

aux2006

Changing users directory location
« Reply #4 on: June 23, 2007, 04:48:51 PM »
mmccarn,

:) (i hope you still have some limb left for us)  SME will not be here until this time if not with people like you.  thank you!
 
actually i will be migrating more than 2000 accounts with more than 70 groups from Netware 4.11, with around 150-200 active users connected most of the time.  i am required to do such directory structure for easy maintenance (they don't want to see all the account at once).  One of the systems we are looking at to migrate to is SME, and we are trying to find ways if certain things can be done in SME, if not then we have to live with SME's defaults so that no tweaking will be made to the system.

Because of people like you that are willing to answer and give ideas of what we can do (especially to those who are new to SME) is a great privillege.

have a great day!

aux

Offline mmccarn

  • *
  • 2,651
  • +10/-0
Changing users directory location
« Reply #5 on: June 23, 2007, 07:25:09 PM »
Quote from: "aux2006"
i will be migrating more than 2000 accounts with more than 70 groups from Netware 4.11
Sounds like quite a project.

You may also want to look into the 'lazy admin tools': http://forums.contribs.org/index.php?topic=37284.0 which allows you to create users, groups, ibays, pseudonyms, &c using text files...


Quote from: "aux2006"
SME will not be here until this time if not with people like you. thank you!
Thanks for the kind words.  I can never decide whether my work-around solutions are useful or not.  I frequently suspect that the developers (who deserve much more credit than I) get quite frustrated when I outline a complicated custom templating project that a) may not work, and b) may break three other subsystems I haven't figured out yet...

aux2006

Changing users directory location
« Reply #6 on: June 25, 2007, 02:05:21 AM »
Quote
You may also want to look into the 'lazy admin tools'


hehehe! a funny name but this contrib is a big big help!