Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.development.apps > #467
| From | "Joe Shead" <Joe@SheadProgramming.com> |
|---|---|
| Newsgroups | comp.os.linux.development.apps |
| References | <s5KdnY85luiJChHSnZ2dnUVZ_uGdnZ2d@earthlink.com> <jmiu3v$is7$1@speranza.aioe.org> <LaydnQXV_ti8FBLSnZ2dnUVZ_qmdnZ2d@earthlink.com> |
| Subject | Re: fopen() of a read-only file for writing? |
| Date | 2012-04-20 19:10 -0600 |
| Message-ID | <mN-dnT01Ved8ZwzSnZ2dnUVZ_tGdnZ2d@earthlink.com> (permalink) |
Hi everyone, The file system I'm working with has been a problem. The machine is multi-boot. I've been working on a C++ utility class library, that compiles in two programming environments in MS Windows (Borland C++Builder 6, and Visual Studio 2003), and in linux, and I've written an extensive test program for it. Things have to pass in all three environments, which is where the fopen() thing came up (which I consider solved, now, in several ways). So, the library resides on a FAT file system. The FAT file system has space in the directory for only one set of permission attributes, and I don't think there is any 'owner' of the file. So, when I mount that partition, linux has to interpret the FAT directory information in terms of linux file system idioms. It assigns an owner and a group to each file, and so what's it going to be, but root and root? And there's the rub, which I worked on yesterday into the wee hours. So, the way that I initially got a test using a user other than root, 'joe', was to do a make on the linux tester project for my utilities, logged on as root in one virtual console, and have root copy the executable file, 'sptest', over to the home directory for 'joe', and have root do a chown() to 'joe' on that file, and I tried out various settings with chmod(). I then ran it in a different virtual console, logged in as joe, which worked as expected. When joe sets his own w bit (u-w) to off, then joe can't open his own file. Now, that's basically what I did to test what Alan told me. Rainer's points----------- I then tested Rainer's 'immutable' point. The file system for most of my linux setup is ext3. Setting the immutable bit with chattr() worked simply. Even root can't open that file for writing. I've got it all backed up. There's no point in proceding if you don't back up your stuff. But, when programming, you still want to know that your stable utilities are the same as they are in your archived 'freeze' file. When I am done working on a version of the utilities, I zip them up in a file with a name like: spUtils01.01.02_20070820_int.zip. That's my last freeze, with version number and date in the file name, and in a form that will have them automatically order correctly alphanumerically. While working on it, daily backups are done in other ways. It's really nice to have each stable version boxed up in that zip, though. Richard's and Grant's points------------ I couldn't find CAP_DAC_OVERRIDE in my info system, so I went on to other things. Regarding rooting, I've got a bad habit of logging on as root in linux, and as Administrator in ms windows. Life is easier that way, but I agree that it has its pitfalls. I'm not too worried about deleting dll's in System32, or system commands in linux, but I imagine that the probability of a hacker or malware getting going with elevated privileges is probably higher if you're logged on as the most powerful user. It's just that, as a programmer, I'm often times trying to figure out what's wrong with something, and I don't like the idea of things being hidden from view. Also, in the mid to late '90's, I became very distrustful of Windows and installation programs. Second, I discovered that in some ways I was limited to being only one user. When I create a user in Windows, and log on as that user, I discover that none of my installed software is available. It was installed under Administrator. So, there were entanglements. So, anyway, in linux, as of now, I'm trying to function as a normal user as much as possible, to take your advice, and because I think it's probably better for security (don't roll your eyes). What I did was to make two bash scripts, that I run when I'm entering linux after working in windows, and another to run before rebooting and going over to windows. One copies the utilities and linux-related parts of the spUtils directory tree using about a half-dozen cp commands from the FAT file system into a tree under joe's ext3 home directory, and the other takes them back. It took probably about six hours to get those straight, and I have previous experience with bash scripts. I use the -u and --preserve=timestamp options, which seems to do the trick. I can't see the commands, so I hope I've got that --preserve option spelled right. It apparently means to transfer the timestamp from the source file to the destination file. I run the two scripts logged on as root, because they access the mounted FAT file-system. Then, I can logout as root and logon as joe, or do an su. I don't have sudo on my installation, but it looks like I could use that to run the two scripts, and never directly logon as root. I just took a look at https://www.linux.com/learn/tutorials/306766-linux-101-introduction-to-sudo. Also, for anybody reading this, I should mention that, regarding the original problem, what Alan said is explained very well in info, under the section "File System Interface." Anyway, thanks again for your help and advice, Joseph Shead President Shead Programming
Back to comp.os.linux.development.apps | Previous | Next — Previous in thread | Next in thread | Find similar
fopen() of a read-only file for writing? "Joe Shead" <Joe@SheadProgramming.com> - 2012-04-16 17:03 -0600
Re: fopen() of a read-only file for writing? pacman@kosh.dhis.org (Alan Curry) - 2012-04-17 05:12 +0000
Re: fopen() of a read-only file for writing? "Joe Shead" <Joe@SheadProgramming.com> - 2012-04-17 01:36 -0600
Re: fopen() of a read-only file for writing? "Joe Shead" <Joe@SheadProgramming.com> - 2012-04-18 22:40 -0600
Re: fopen() of a read-only file for writing? Richard Kettlewell <rjk@greenend.org.uk> - 2012-04-19 08:57 +0100
Re: fopen() of a read-only file for writing? Rainer Weikusat <rweikusat@mssgmbh.com> - 2012-04-19 14:18 +0100
Re: fopen() of a read-only file for writing? Grant Edwards <invalid@invalid.invalid> - 2012-04-19 14:16 +0000
Re: fopen() of a read-only file for writing? "Joe Shead" <Joe@SheadProgramming.com> - 2012-04-20 19:10 -0600
Re: fopen() of a read-only file for writing? Richard Kettlewell <rjk@greenend.org.uk> - 2012-04-21 10:20 +0100
Re: fopen() of a read-only file for writing? "Joe Shead" <Joe@SheadProgramming.com> - 2012-04-22 00:07 -0600
Re: fopen() of a read-only file for writing? "Joe Shead" <Joe@SheadProgramming.com> - 2012-04-23 15:24 -0600
csiph-web