Protecting files

This is a discussion on Protecting files within the Linux Programming forums, part of the Platform Specific Boards category; How do I protect files in Red hat linux 7 from people who log in uder the same user account? ...

  1. #1
    Student Forever! bookworm's Avatar
    Join Date
    Apr 2003
    Posts
    132

    Question Protecting files

    How do I protect files in Red hat linux 7 from people who log in uder the same user account?
    Maybe some encryption or password protection,I don't know,could u please guide me?

  2. #2
    Obsessed with C chrismiceli's Avatar
    Join Date
    Jan 2003
    Posts
    501
    You could simple hide it with the by putting a "." as the first character in the file name. For example: /home/user/.hiddenfile
    The hidden file will now not be able to show up with a simple ls, you will need a ls -a or ls -A. Another way would be to encrypt it yet. A 3rd way is to put it in a directory and mount something over it. There will be no way to access the file(except links), unless the unmount is done, that requires some root access though.
    Last edited by chrismiceli; 06-12-2004 at 03:16 PM.
    Help populate a c/c++ help irc channel
    server: irc://irc.efnet.net
    channel: #c

  3. #3
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    how bad do you not want them to see it. You could do as chrismiceli. Your could encrypt it. Here is a simple one(depends on how tech-savy the other person it to figure it out);
    Code:
    Code:
    /*An simple encryption program*/
    #include <stdio.h>
    #include <stdlib.h>
    
    int main(int argc,char **argv){
            FILE *in;
            FILE *out;
            int x=1,y=0;
            char buffer[BUFSIZ];
            if(!(out=fopen("encrypt","wr"))){
                    printf("Could't create file\n");
                    exit(1);
            }
            if(argc<2){
                    printf("Usage ./simple file\n");
                    exit(0);
            }
            while((in=fopen(argv[x],"rw"))){
                    while(fgets(buffer,sizeof buffer,in)){
                            while(buffer[y]){
                                    buffer[y]^=13;
                                    y++;
                            }
                            fprintf(out,"%s",buffer);
                    }
                    fclose(in);
                    x++;
            }
            fclose(out);
            return 0;
    If you can use this great. But I was just joking when I wrote this. To decrypt run it on the ecrpyted file

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    At the command line prompt, type

    apropos crypt

    And use whatever tools / libraries are present on your machine
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    SleepWalker tjohnsson's Avatar
    Join Date
    Apr 2004
    Posts
    70
    ... or just change file permissions with chmod.

  6. #6
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    he said it was the same user though. So it wouldn't be that helpful for him either, if they both can be root also. He didn't specfy maybe they always run as root. You never know.

  7. #7
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    Well not having separate user accounts is a missed opportunity anyway.
    If you want to share some files, then make both users part of the same group.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. add source files to embedded VC 4.0
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2006, 03:28 AM
  2. *.cpp and *.h files understanding
    By ElastoManiac in forum C++ Programming
    Replies: 4
    Last Post: 06-11-2006, 04:45 AM
  3. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 10:46 AM
  4. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 01:41 PM
  5. header and source files
    By gtriarhos in forum C Programming
    Replies: 3
    Last Post: 10-02-2005, 03:16 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21