Gnome Text Editor changing permissions on "recycled" scripts.
UbuntuThis forum is for the discussion of Ubuntu Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Gnome Text Editor changing permissions on "recycled" scripts.
By "recycled" I mean scripts composed in some other editor.
I've had it happen a few times in the last month. I'll find something a little off in a script I've brought over to the Ubuntu install on my laptop from Cygwin on my Windows XPSP3 running desktop machine, and when I go to run it in GNOME Terminal after editing it to suit my purposes in gedit, I get a Permission Denied error message.
Invariably, when I check the perms with an ls -al <filename>, they've been reverted to a 606 or something just as limited. Certainly no execution bit set.
Can someone explain why this would be happening? What can I do to remedy it?
I am guessing that Cygwin really does act like a Linux system. Linux keeps the user name in the file inode as a user number. You could have the same user name on different Linux systems but the systems could have assigned different user numbers to the user names that you have created. Ubuntu would probably limit access to a file with a user number that does not correspond to any user names in its user name table. Check the user number on both Cygwin and Ubuntu with this command:
id -u username
If Cygwin cannot be made to conform to your Ubuntu user name/user number system then you could assign the user name, group name, and permissions to any file you copy to Ubuntu after you copy the file.
-----------------------
Steve Stites
P.S. The same potential problem also exits with group names/group numbers.
So in other words, if Gnome doesn't see a Cygwin-assigned execution bit, gedit will do the safe and reasonable thing and just give the owner edit (and not execute) permissions?
How about for scripts which I've chmod'ded a+x (or its octal -- escapes me at the moment) in GNOME Terminal and gedit still "steals" the x bit after an edit & save? I've had that happen as well, though not as often.
The routine that is trying to make sense out of the owner, group, and permissions data is the file system module. When whatever program says save the file the file system module will try to set up the permissions. That it does so incorrectly could be due to several possible problems including your idea that Cygwin is not passing an execute permission bit. My original thought was that the user number or group number might be one that Ubuntu does not recognize so when the file system tries to look up the default permissions for that user name it finds that it is an invalid user name.
You could check to see what permissions, user number, and group number Cygwin has for the file and and then check the user number and group number to see if Ubuntu recognizes them.
End-up: they're not the same. It looks like it will be necessary for me to change attributes on any scripts as I copy them from one machine to the other. Maybe I'll write a script that works exclusively on BASH scripts to do it...shouldn't be too hard; just grep the output of file <foo> for "script text executable" and run a chmod-chown-chgrp triple-dip on the valid ones.
Thanks for all your help. I thought maybe my gedit was wearing out.
BZT
Last edited by SilversleevesX; 09-23-2011 at 08:27 PM.
I just edited and saved a BASH script in Gnome Editor that I wrote in Geany, after I added the execution bit to it in Gnome Terminal. gedit got rid of the execution bit.
Now it's doing it to "its own," ie, scripts written and saved in the same OS, on the same machine and with no more of a change to the content -- in this instance -- than an OR replaced by an AND -- textually, btw, not as part of any command.
I'd just like folks to be aware that it's possible. It's bad enough Windows text editors, whose authors boast of their "cross platform capabilities," do this (and I know the reasons: they're in the foregoing posts in this thread). I don't know why, exactly, the folks who work on gedit would leave out the preservation of permissions as read.
There's not even a pref for it, though there is now a plug-in, which I think is in the "standard" set which installs with the application, that claims to be able to execute scripts from within the editor.
I'd like to ask the author of that plug-in "How?" but my French isn't that great.
BZT
Last edited by SilversleevesX; 12-24-2011 at 08:55 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.