Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a Windows 7 host, with a CentOS 6 guest under VirtualBox.

I have a Windows directory shared with the Linux guest using CIFS.

Everything worked fine so far, until I realized that all chmod operations yield:

chmod: changing permissions of `x': Operation not permitted

This is understandable, but my problem is that some tools I have no control on, attempt to chmod files for me, and fail as a result.

Is it possible to allow but ignore all chmod() calls on a CIFS mount? Please note than these calls are made from a programming language and not from the command-line chmod utility.

Edit: the manual for mount.cifs says (emphasize mine):

The core CIFS protocol does not provide unix ownership information or mode for files and directories. Because of this, files and directories will generally appear to be owned by whatever values the uid= or gid= options are set, and will have permissions set to the default file_mode and dir_mode for the mount. Attempting to change these values via chmod/chown will return success but have no effect.

That's exactly the behaviour I'm after then, so why is it not working for me?

share|improve this question
    
Please could you clarify what programming language, and what you are actually trying to achieve with the programming language. Allow but ignore on the face of it seems to be contradictory. With further background will help us provide insight into your problem. –  David Apr 21 at 21:55
    
I don't think you can get all permissions modifications to be ignored . . . does the script actually bail out when the file permissions are modified, or does it bail out later as the permissions are not sufficient? If they're not sufficient, you could use mount options (file_mode and dir_mode) to set all the files to have the permissions you need . . . –  ernie Apr 22 at 0:21
    
@David Again I don't have control over the tool, which I believe is programmed in C, and makes calls to the system's chmod() function. @ernie It bails out when the file permissions are (trying to be) modified, and does not complete. –  Benjamin Apr 22 at 6:31
    
For information, I'm trying to install a PEAR package for PHP over Composer, and the script fails because its PHAR package installer tries to chmod() some files. The exact error is: Extraction from phar "..." failed: Cannot extract "package.xml" to "...", setting file permissions failed. –  Benjamin Apr 22 at 6:35
    
Thanks, this was the background that we where looking for. Can you add additional permissions on your Windows system to permit what is happening in the install script? It sounds almost as though the script is trying to set something to executable, which just may not work on a windows share. –  David Apr 22 at 9:17

2 Answers 2

up vote 1 down vote accepted

Found it: the noperm mount parameter does exactly this:

//192.168.56.1/www /mnt/www cifs noperm,username=www,password=xxx, ...

Note that mount -a does not apply the parameter, you have to reboot to make it work.
It took me a lot of trial and error to figure this out.

Now chmod works fine, the command does not yield any error, and is just ignored.

share|improve this answer
    
Why reboot when you can just unmount and mount again? Maybe CIFS can even remount. –  Daniel B Apr 25 at 11:44
    
Shouldn't mount -a unmount and remount as well? –  Benjamin Apr 25 at 11:50
    
No. That would be fatal. It only mounts currently unmounted filesystems from /etc/fstab –  Daniel B Apr 25 at 12:41

Try adding exec option. I believe mounting as a non-root user will turn off exec.

http://unix.stackexchange.com/questions/34822/is-it-possible-to-enable-execution-of-files-from-a-cifs-mount-in-bash

share|improve this answer
    
Same thing I'm afraid with exec: operation not permitted. –  Benjamin Apr 24 at 13:02
    
try mounting as root? –  David Apr 24 at 22:17
    
Well, looking at a couple further articles, you can not chmod +x to a file on a windows share. You have marked all the files as executable by using using the option file_mode=0777 anyway. I would suggest installing the pear module on a folder in the linux file system, then copy it over. –  David Apr 24 at 22:24
    

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.