Re: chown/chmod -R from kernel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 30, 2004 at 12:25:04 +0200, Domen Puncer wrote:
> On Tue, Mar 30, 2004 at 11:02:57AM +0200, Jan Hudec wrote:
> > On Tue, Mar 30, 2004 at 02:00:25 +0200, Domen Puncer wrote:
> > > I've been trying to fix usbfs bug (bugme 1418), and i have problems
> > > implementing chown/chmod.
> > > 
> > > I've come up with following code (outputs 4xabd, even when there should be
> > > directories; nothing seems chmoded in /proc/bus/usb/)
> > > 
> > > Any pointer what did i do wrong appreciated.
> > 
> > You shouldn't do chmod from kernel. You should call_usermodehelper.
>
> But then I have to set chmod path somewhere?
 
IIRC there is a function to convert dentry to a path -- d_path or
something like that.

> > Dentry cache is a cache -- it does not hold ALL the files. Only some of
> > them. At mostly random.
> 
> Hmm... then how could i change it from kernel?

You must call to the filesystem driver. Procfs may not support the
necessary calls however (in which case chmod won't work either).

> > Permissions for /proc files must be fixed in the code that registers
> > them.
> 
> Problem is that files are created before mounting usbfs (with devuid
> etc. options).

Then it has to be fixed in the code that registered them ;-).

It does not matter WHEN they are created.

For a proc file, the structure that is registered with proc_register
(proc_dir_entry) is authoritative. You have to change the mode there.

If the code registers a ->set_attr method to the inode_operations
vtable, than you can use it's guts (to operate on the proc_dir_entry
directly and not via an inode).

Otherwise you need to manipulate the proc_dir_entry structures, but be
aware, that there might be other things that need fixing too.

Probably the best way is to modify the code so it either only registers
the proc files when usbfs is mounted (and it's options known) or it is
able to re-register them when the uid changes.

Note: The mountpoint get's permissions from root of the mounted fs, not
from the mountpoint.

> > > 
> > > 	Domen
> > > 
> > > struct dentry *dentry;   
> > > list_for_each_entry(dentry, &s_root->d_subdirs, d_subdirs) {  
> > > 	printk("a\n");     
> > > 	if (!dentry->d_inode)    
> > > 		continue;     
> > > 	printk("b\n");     
> > > 	if (dentry->d_inode->i_mode & S_IFDIR) { 
> > > 		printk("c\n");     
> > > 		struct dentry *devd;   
> > > 		     
> > > 		dentry->d_inode->i_uid = busuid;   
> > > 		dentry->d_inode->i_gid = busgid;   
> > > 		dentry->d_inode->i_mode = busmode & S_IFDIR; 
> > > 		     
> > > 		list_for_each_entry(devd, &dentry->d_subdirs,    
> > > 				d_subdirs) {    
> > > 			dentry->d_inode->i_uid = devuid;   
> > > 			dentry->d_inode->i_gid = devgid;   
> > > 			dentry->d_inode->i_mode = devmode & S_IFREG; 
> > > 		}     
> > > 	} else {   
> > > 		printk("d\n");     
> > > 		dentry->d_inode->i_uid = listuid;   
> > > 		dentry->d_inode->i_gid = listgid;   
> > > 		dentry->d_inode->i_mode = listmode & S_IFREG; 
> > > 	}     
> > > }     
> > > 
> > > --
> > > Kernelnewbies: Help each other learn about the Linux kernel.
> > > Archive:       http://mail.nl.linux.org/kernelnewbies/
> > > FAQ:           http://kernelnewbies.org/faq/
> > > 
> > -------------------------------------------------------------------------------
> > 						 Jan 'Bulb' Hudec <bulb@ucw.cz>
> 
> 
> 
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/
> 
-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@ucw.cz>

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux