473,323 Members | 1,550 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Need to protect a file

Hi all,

In my server we login with a common userid/passwd. There is a file created with this Id and everyone has acess to modify the contents. We need to restrict this in such a way that when a person tries change certain this in the file he should be restricted in doing it.

Basically It should ask for a passwd before saving the file so only few within the same group will have control to do so...

Note: We cannot use root passwd. We cannot change the perm of file as every user logins with the same user/passwd they can also change the perm...
Jul 11 '08 #1
4 1974
Forgot to mention the OS it is linux file. The filename extension also should not be changed.....

Thanks in Advance..
Jul 11 '08 #2
Nepomuk
3,112 Expert 2GB
Well, the idea behind the Linux (and Unix) user system is, that everybody should have their own account. With that, you should be able to protect any files of your own from anyone else via
Expand|Select|Wrap|Line Numbers
  1. chmod 700 my_file
for no access by others, if others should be able to execute it:
Expand|Select|Wrap|Line Numbers
  1. chmod 711 my_file
and if they should be able to execute and read, but not write to it:
Expand|Select|Wrap|Line Numbers
  1. chmod 755 my_file
If that is not an option, we'll have to think of something else. You could of course hide the file by just renaming it
Expand|Select|Wrap|Line Numbers
  1. mv my_file .my_file
but anyone who knows it's there or has a look at hidden files will see it.

Next thought that comes to mind is file encryption. I've never used single file encryption before, but there should be plenty of tutorials on the web. It would allow only that person, who knows the code, to change it (while knowing, what he/she's doing). I guess it could still be deleted, but at least no one could just change it without you noticing.

Can't think of any better method right now.

Greetings,
Nepomuk
Jul 11 '08 #3
Laharl
849 Expert 512MB
I would recommend creating a group, myfile_editors or some such, and change the owner of the file (via chown) to that group. Then add everyone that needs edit access to the group and set the permissions with chmod, possibly to 744 (owner does anything, anybody else can read it and not execute, 755 gives execution rights as well).

This does require you to create actual user accounts. There is probably a way to password-protect the file, but I don't know how, I'm afraid, other than some sort of shell script...
Jul 11 '08 #4
Hi,
I would like to provide a further suggestion. It MAY work for your case. You may change the 'sticky-bit' of the file, the same way you change your file permission.(chmod or through some file-manager). In this way, it gets locked in the SWAP SPACE, and files residing there cannot be changed. This should THEORITICALLY provide some speddup in access-latency as well, but on modern computers, it hardly matters. You may chage the sticky-bit every time you want to allow some users, and lock it back when you want it protected.

Try it, it may solve the preoblem!

Bye.
Jul 12 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Kevin C. | last post by:
I'm going to write a client-side web app that deals with local files. This web app targets mainly public or corporate browser terminals. Normally I would write an Applet because that's what I know...
7
by: emanshu | last post by:
HI all, I an designing an application in C++. i want to open file requested by end user but i want to reflect an error to user if file is already opened by some other application.. will anybody...
1
by: Sergey P. Vazulia | last post by:
this part of my code: f = file(work_dir + filename,'r') n = int(totalSize/recordLenth) i = 0 while i < n: buf = f.read(recordLenth); sometime (when find something like \0A\00\00 in data)...
2
by: shwetu | last post by:
Need a file dialog box in asp.net 2.0 which selects folder not single file
1
by: steve | last post by:
Hi, Hoping some one can help here, trying to get xampp....0.8.1.sh for solaris 9 x86. I only have access to the web via a windows box to download the .sh file. Windows corrupts the file so can...
3
donilourdu
by: donilourdu | last post by:
hi all, I need sample code for convertion images to pdf format in vb.net.Also tell the free dll file for that . Looking for favor.......... with regards, Doni Agna Lourdu.M
6
by: shalmi27 | last post by:
hi every1 me new to this forum.... well i really need help... i want a c++ file handling program... for eg: like hotel management,games,railway reservation...... the program..must b able to...
0
by: gsuns82 | last post by:
Hi all, can u name the jar to be used for <%@ taglib uri="/tags/taglib" prefix="comp"%> in my jsp page??? Thanks&Regards, sundar
1
by: tenii | last post by:
Using the following:$rec_email = "dearMe@myplace.com"; // send this email to myself $subject = "My Form"; // please tell me how I can add additional email addresses that my form can go to. I've...
3
by: msalmanzaib | last post by:
Help me i want to store data of this program to a text file. my compiler is Dev C++ . Data code for text file is in bold form ::Full code deleted, please post only the relevant text and errors::
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.