LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 09-23-2011, 12:10 AM   #1
SilversleevesX
Member
 
Registered: May 2009
Posts: 181
Blog Entries: 9

Rep: Reputation: 15
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?

BZT
 
Old 09-23-2011, 05:47 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
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.

Last edited by jailbait; 09-23-2011 at 06:07 PM.
 
1 members found this post helpful.
Old 09-23-2011, 06:06 PM   #3
SilversleevesX
Member
 
Registered: May 2009
Posts: 181

Original Poster
Blog Entries: 9

Rep: Reputation: 15
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.

BZT
 
Old 09-23-2011, 06:40 PM   #4
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
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.

--------------------
Steve Stites
 
Old 09-23-2011, 08:20 PM   #5
SilversleevesX
Member
 
Registered: May 2009
Posts: 181

Original Poster
Blog Entries: 9

Rep: Reputation: 15
Smile

Got it -- I think.

My UID in Cygwin is 1003.

My UID in Ubuntu is 1000.

Changing the former to the latter is no good, as 1000 is taken (by MS HelpAssistant).

Instead of a script, I used a JPEG file to compare permissions. The Cygwin perms on the file are
Code:
-rwx------+
(That "+" sign is a Cygwin flag to denote the presence of Windows ACLs)

The permissions on the same file in Ubuntu read as
Code:
-rwxr-xr-x
The above were, obviously, each the outputs from an ls -al command. From stat the relevant lines are:

Cygwin:
Code:
Access: (0770/-rwxrwx---)  Uid: ( 1003/   steve)   Gid: ( 1006/resurgam)

(NB: I did a chmod on this file after I ls'ed it.)
Ubuntu
Code:
Access: (0755/-rwxr-xr-x)  Uid: ( 1000/   steve)   Gid: ( 1000/   steve)
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.
 
Old 12-24-2011, 08:54 PM   #6
SilversleevesX
Member
 
Registered: May 2009
Posts: 181

Original Poster
Blog Entries: 9

Rep: Reputation: 15
I'm back.

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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] "Go Advanced" text editor should be horizontally wide. Aquarius_Girl LQ Suggestions & Feedback 5 11-23-2010 10:31 AM
Lost option to "Open with text editor" executable script in 8.04 taylorkh Ubuntu 2 02-04-2009 10:49 AM
Gnome MIME issue - everything's a "plain text document" ciotog Linux - Desktop 3 10-27-2008 09:30 PM
LXer: Displaying "MyComputer", "Trash", "Network Servers" Icons On A GNOME Desktop LXer Syndicated Linux News 0 04-02-2007 08:31 AM
Installed jEdit, only get "Starting Programmer's Text Editor" Nathan1993 Ubuntu 6 03-29-2006 12:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 11:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration