From kde Tue Jan 05 13:50:16 2010 From: Stef Bon Date: Tue, 05 Jan 2010 13:50:16 +0000 To: kde Subject: [kde] 2try: Idea to get proper access to all kind of resources Message-Id: <4B434398.7000609 () bononline ! nl> X-MARC-Message: https://marc.info/?l=kde&m=126269951018474 Hello, I've been working on a construction for a long time now, and te create easy, functional access to all kind of resources like SMB shares, FTP servers, SSH and USB devices while making use of the best tools to mount them. In the case of SMB shares that is mounting with cifs. Prepare for a long story, it's not so easy to explain. This construction is based upon two techniques I've integrated to work together. The first one is the automounter, which mounts targets on demand. In my construction it is designed to work with what I call resource records. These records contain all the infromation about a resource and how to mount it. It looks like: /var/cache/mount.md5key/b4a0859ac795f50baf7e43ff4f49f314 contains .directory config permissions SMB_services The name of this record is b4a0859ac795f50baf7e43ff4f49f314, all the information is in the config file. Other files do have a meaning, but it's to complicated to tell about that here. The config file looks like: RECORD_type=smb RECORD_security=private RECORD_creator=discover-smb-resources.sh LOCAL_user=sbon SMB_workgroup=BONONLINE SMB_name=LFS20060812 SMB_share=public SMB_ip=192.168.0.2 SMB_auth_method=private SMB_credential_file=/home/sbon/.smb/mount.cred Now the automounter makes use of these records the following way An apart auto.master (created for this purpose only) is in /var/run/autofs, looking like: /mnt/mount.md5key/sbon/mount /etc/autofs/auto.md5key MD5KEY_USER=sbon /mnt/mount.md5key/root/mount /etc/autofs/auto.md5key MD5KEY_USER=root (users sbon and root are making use this construction) where the auto.md5key is: * -fstype=md5key :/& Very simple and straightforward, just passing every key to the mountcommand of the nonexistent filesystem md5key. This mount.md5key is a wrapper, and intelligent enought to do a lookup of the key, and launch the right mount command, in the case of SMB this is mount.cifs. So when I do: ls /mnt/mount.md5key/sbon/mount/b4a0859ac795f50baf7e43ff4f49f314 the share //LFS20060812/public is mounted there, using credentials (which are stored in a file). Maintenance of these resource records are done trhough scripts (making use of utilities like nbtscan, nmblookup and smbclient) Now this constrcution is not to be used directly, but in cooperation with a fusemodule I've developed. But first, you can make use of this mounting ability, by creating a tree with symlinks: A "Windows Network" tree may look like: /home/sbon/Network/Windows Network/BONONLINE/ADMIN/admin -> /mnt/mount.md5key/sbon/mount/50b89942f697f095ac66359eae1b3a8f /documentation -> /mnt/mount.md5key/sbon/mount/68141c6ce3077c8e438f7b31c3002053 /public -> /mnt/mount.md5key/sbon/mount/795e5d59a7901e91296cf6aae0987c94 /sbon -> /mnt/mount.md5key/sbon/mount/8236f6c5eae783204a24f447c4ea8ec3 Now this works, but is not userfriendly in my opinion. When browsing to these links and following them, most applications forget the place where they are coming from, and the user ends up browsing in /mnt/mount.md5key/... tree, for an average user a strange place. Should not happen. (there are more cons to this, every time an user enters this directory all targets are mounted, cause most applications want to "know" what symlinks are ointing to. Also most apps in KDE look for a .directory file, also causing unnec. mounting) So that;s why I've created the FUSE mocules fuse-workspace and fuse-workpace-union. The first is a first try, with hardcoded paths. The second one it way more advanced, with different parameters, and has integration with the automounter, and can do some caching. Now these modules are overlay filesystems, which "mirror" another directory (the "bind" directory) into the mounted dir, just like the fusexmp (part of the FUSE source) does with the root (/) . Next to mirror, they are able to make symlinks (to dirs) look like directories. mkdir -p /home/sbon/.fuse/bind mkdir -p /home/sbon/.fuse/conf mv /home/sbon/Network /home/sbon/.fuse/bind mkdir /home/sbon/Workspace fuse-workspace-union --bind-directory=/home/sbon/.fuse/bind \ --conf-directory=/home/sbon/.fuse/conf \ /home/sbon/Workspace Now without any action the symlinks above remain unchanged: cd /home/sbon/Workspace/Network/Windows Network/BONONLINE/ADMIN ls -l lrwxrwxrwx 1 root root 61 2009-12-31 21:17 admin -> /mnt/mount.md5key/sbon/mount/50b89942f697f095ac66359eae1b3a8f lrwxrwxrwx 1 root root 61 2009-12-31 21:17 documentation -> /mnt/mount.md5key/sbon/mount/68141c6ce3077c8e438f7b31c3002053 lrwxrwxrwx 1 root root 61 2009-12-31 21:17 public -> /mnt/mount.md5key/sbon/mount/795e5d59a7901e91296cf6aae0987c94 lrwxrwxrwx 1 root root 61 2009-12-31 21:17 sbon -> /mnt/mount.md5key/sbon/mount/8236f6c5eae783204a24f447c4ea8ec3 Now create directories in the conf tree, to instruct fuse-workspace-union to translate the symlinks to shares to directories install --directory /home/sbon/.fuse/conf/Network/Windows\ Network/BONONLINE/ADMIN/admin install --directory /home/sbon/.fuse/conf/Network/Windows\ Network/BONONLINE/ADMIN/documentation install --directory /home/sbon/.fuse/conf/Network/Windows\ Network/BONONLINE/ADMIN/public install --directory /home/sbon/.fuse/conf/Network/Windows\ Network/BONONLINE/ADMIN/sbon Now the same command cd /home/sbon/Workspace/Network/Windows Network/BONONLINE/ADMIN ls -l drwxr-xr-x 2 sbon netgroup 61 2009-12-31 21:17 admin drwxr-xr-x 2 sbon netgroup 61 2009-12-31 21:17 documentation drwxr-xr-x 2 sbon netgroup 61 2009-12-31 21:17 public drwxr-xr-x 2 sbon netgroup 61 2009-12-31 21:17 sbon Now when listing the contents of this directory does not make all targets to be mounted. This does not only work for SMB shares, but also for FTP, SSH and I'm convinced for IPX( Novell Netware) also. And for local resources like USB devices. Right now there is mounting by HAL of these devices, but I'm not so happy with that. (soon to be replaced by udisk) The problem is that mounting of a device by more than one user (MultiSeat!!) is not possible. I've posted serveral meddages about this topic in de hal and udisk maillist, no reply recieved) With this construction, no problem. Each user has her/his own (autofs managed) mountpoint in /mnt/mount.md5key/... with her/his own options, and this is mirrored into her/his homedirectory. I' do not have investigated this futher, but by mirroring the mountpoints to somewhere in your homedirectory, maybe it's also possible to do some translation from charset to charset... Now, it's easy to add the automounted directory and the fuse-workspace-union mounted when a session starts through ConsoleKIt (and the at daemon) which has the ability to run scripts when a session is added (and when a session is removed) Futher is also not so hard to automate the proces of maintaining the "resource records". Through a script which looks for SMB server with nbtscan and determines the shares with smbclient for every user looged in, and run that every 5 minutes. And it's possible to automate the propagation of changes into the connections trees in the homedirectories of users. Now I write this email to get this construction work better with KDE. Gnome has something also with FUSE (the Gnome Virtual Filesystem/ gio). And in my opinion KDE needs something better than kio slaves! This construction makes use of real paths, making resources available just for every application, just like entering a directory. It's making use of the cifs filesystem to access SMB shares, which has more features than the kio slave for smb, like support of ACL/.ATTR, oplocking, transparant uid/gid/permission in environments with a shared id database like LDAP or ADS (with winbind). And mentioned above more servives like FTP, IPX and local mounting is possible. More about this: http://linux.bononline.nl/linux/mount.md5key/index.php http://linux.bononline.nl/linux/runsessionscripts/index.php http://linux.bononline.nl/linux/fuse-workspace/index.php Hhere you'll find also screenshots. Note the icons, I'v put a lot of effort in making fuse-workspace-union handle these right. I hope I recieve at least a reaction what you think. Any reaction is welcome. I've put a lot of effort in developing this constrcution, learned C, and posted about this before, but very few reactions, while I'm convinced that this construction has potential. On my system it's working, and I'm very happy with it. It's so convenient and functional. I know that the documentation is not up to order, but I'm working on it. Maybe this should go to brainstorm, maybe. Stef Bon ___________________________________________________ This message is from the kde mailing list. Account management: https://mail.kde.org/mailman/listinfo/kde. Archives: http://lists.kde.org/. More info: http://www.kde.org/faq.html.