flat assembler
Message board for the users of flat assembler.

Index > Main > Mixed Windows/Linux question.

Author
Thread Post new topic Reply to topic
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
When compiling ELF executable in Windows, is it possible to set its "executable" flag, so later, when I copy this file to Linux, it can be executed without need for "chmod"-ing it.

It should be possible, because, I copied some executable file from Linux to NTFS (using Windows) and then back to Linux and it kept its "executable" status unchanged.

_________________
Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9
Post 25 Sep 2012, 16:57
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
File permissions are not part of the file data, so this won't be portable. It sounds like you replaced the file instead of creating a new one going from Windows->Linux so it inherited the current permissions.

You can use programs like WinSCP to copy and set permissions.
Post 25 Sep 2012, 18:32
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
cod3b453 wrote:
It sounds like you replaced the file instead of creating a new one going from Windows->Linux so it inherited the current permissions.


No, I am not. The experiment is clean.
More, I figured out what actually happens. If the file have "system" attribute set (attrib filename +S) in Windows/DOS, Linux will accept it as an executable file (chmod +x filename).

Try it yourself: Compile some ELF executable with FASM in Windows. Make a copy of the executable and then set system attribute for only one of the copies: "attrib filename1 +S", then copy these two copies in Linux FS. You will see, that only the system file has executable permissions set.

_________________
Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9
Post 25 Sep 2012, 18:55
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
Interestingly, copying over Samba to my server actually worked without doing anything, so it must have picked up the fact it was a ELF...
Post 25 Sep 2012, 19:22
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Try to use FAT32 formatted pen drive.
Post 25 Sep 2012, 20:01
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Feryno



Joined: 23 Mar 2005
Posts: 465
Location: Czech republic, Slovak republic
Feryno
hi, JohnFound
try to copy a file without executable flag from your Linux partition to USB and then back from USB to Linux and I'm guessing the file obtains the executable flag
there is some mask when mounting FAT32 into Linux filesystem and that mask gives the executable flag for every file copied to your USB
http://linux.die.net/man/8/mount
scroll down to:
Mount options for fat
and read about:
umask
Post 26 Sep 2012, 06:27
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
I made some more experiments with these files and the results vary, depending on the software used to transport files.
The trick with the system flag actually works only with CoFS (andLinux) - I believe it is specially implemented this way in order to work more flawlessly with Windows....
Post 26 Sep 2012, 12:02
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Feryno



Joined: 23 Mar 2005
Posts: 465
Location: Czech republic, Slovak republic
Feryno
if you want to keep original file attributes never copy it directly into different/insufficient filesystem
maybe you could store your Linux file with its attributes (perhaps even with its User ID + Group ID) into tar file and then do the transfer with the tarball archive into different filesystem
Post 26 Sep 2012, 13:30
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Feryno wrote:
if you want to keep original file attributes never copy it directly into different/insufficient filesystem
maybe you could store your Linux file with its attributes (perhaps even with its User ID + Group ID) into tar file and then do the transfer with the tarball archive into different filesystem


It is for distribution purposes.
For example, if I have some program, with versions for Linux and for Windows, I can create two packages - one for Windows and one for Linux. (and if the package is big enough it will be the proper solution.) In this case, there is no problems with file permissions.

Another approach is make one mixed package, containing binaries for all supported OSes sharing configuration files and other common parts.

Then the user simply unpack this package to some directory (possibly on removable drive) and takes portable application able to run on any supported platform.

In the case, it seems that after unpacking, the user have to set the permissions for ELF files manually, what is not a big problem, but at least annoying.

_________________
Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9
Post 26 Sep 2012, 13:59
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
cod3b453 wrote:
Interestingly, copying over Samba to my server actually worked without doing anything, so it must have picked up the fact it was a ELF...
Nope, that's because of the "create mask" in your samba config - which you really should probably set to 0640 0r 0600.

_________________
Image - carpe noctem
Post 01 Oct 2012, 14:14
View user's profile Send private message Visit poster's website Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
Well spotted...clearly another victim in my last round of updates Confused
Post 01 Oct 2012, 17:59
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.