#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    4
    Rep Power
    0

    How to implement password access to specific file type in Linux/Windows programmatica


    Linux and Windows question.

    1. I do not want user to launch all ".doc" files (including those he brings in).
    2. User tries to launch a file "test.doc".
    3. The password window appears.
    4. If the password is correct, the file is opened.
    Know how?..

    I read this guide:
    3 Ways to Create a Password Protected File on Windows 7 - wikiHow

    The problem is that I want to do it by mask, not just a few known files.
  2. #2
  3. Lazy Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,325
    Rep Power
    9645
    You can't. Not without designing something that is essentially, if not literally, a virus.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    4
    Rep Power
    0
    Originally Posted by requinix
    You can't. Not without designing something that is essentially, if not literally, a virus.
    I want a virus then. Please help.
  6. #4
  7. Lazy Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,325
    Rep Power
    9645
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2014
    Location
    India
    Posts
    200
    Rep Power
    4
    Originally Posted by Kosarar
    Linux and Windows question.

    1. I do not want user to launch all ".doc" files (including those he brings in).
    2. User tries to launch a file "test.doc".
    3. The password window appears.
    4. If the password is correct, the file is opened.
    Know how?..

    I read this guide:
    3 Ways to Create a Password Protected File on Windows 7 - wikiHow

    The problem is that I want to do it by mask, not just a few known files.
    If you wanted to password protect a single file then I would strongly suggest GPG (GNU's implementation of PGP) instead of using any homegrown encryption method. But what you're asking here is to impede the user from launching a whole class of files which is, as @requinix said, clearly a virus.

    Moreover there's no foolproof way to do this, you could override the default file-manager but you can't really prevent the user from accessing a certain class of files and there are file-permissions and ownership caveats in Linux (or any Unix for that matter), so it isn't realistically possible. You could remove executable permissions from a specific class of files (in your case all *.doc files) but you can't really prevent access this way because in Unix file-extensions are for users only, programs use magic-numbers and predetermined MIME-types. If you really want to prevent access to your files then just use encryption policies such as PGP.

    In *nix, a simple way to prevent other users from accessing a directory that you've ownership to is to change the file permissions using chmod (see man chmod for details), you can use ls -l to view the file-permissions for a specific directory. I believe this can also be done using AppArmor or SELinux but you would have to find out for yourself.

    Bottom line -- don't create a virus to protect your personal files, instead use secure encryption policies (especially those that are asymmetric) and/or file-permissions (applicable for Unixes such as Linux or OS X only).

IMN logo majestic logo threadwatch logo seochat tools logo