开发者

Can I password protect an application? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

I have an application which I don't want people to access unless given explicit permission (via a password). More specifically, this application needs to be "locked" during certain hours of the day unless the user enters a password.

The ability to check the time is simple. The ability to lock the application is what I don't know how to do. The reason that this needs to be done is that the company doesn't trust the user to log out and doesn't want any unauthorized access to the application. This is mea开发者_如何学JAVAnt as a sort of last measure just in case.

I didn't write the application though, so I cant embed a password into it. The machine has only one user and I don't want to create others. My user is an admin as well, therefore most options appealing to use of the os to provide security wont work.

Any ideas on how to accomplish this? I'm dealing with Mac OS X but would prefer an OS independent solution. Any solution involving C or C++ is welcome.

Thanks!


How about you embed the app in an encrypted disk image bundle? As long as the only user that uses it never copies it from there and properly unmounts the bundle afterwards, i think it would accomplish what you want:

  1. Create a new encrypted disk image (DMG) using Disk Utility (this allows you to enter a password), store it anywhere within the user's home directory.
  2. Mount the DMG and place the app you're trying to protect inside it
  3. Create an alias to the app within the mounted DMG and place it on the desktop
  4. Unmount the DMG

After that, when the user double-clicks the alias on the desktop, the user is prompted for the DMG's password. If it's correct, the DMG is mounted and the app is started automatically and directly.

To auto-unmount afterwards perhaps you could script something that uses the diskutil shell command, like this: > diskutil unmount /Volumes/DMG_NAME

All you have to do then is:

  • remove any unencrypted copies of the app from the system
  • explicitly inform your user to unmount the DMG when he's done using the app (or script this to do it automatically)
  • explain to your fellow StackOverflowers what the actual issue is that you're solving. Msw has a point and I hope you can elaborate a bit.


Obviously with this set-up nothing's going to be 100% secure, but for casual users you can encrypt the application with the password, then write a launching application that decrypts and launches the application when the password is entered, and deletes the application when it quits.


#include <stdio.h>
#include <string.h>

char buf[BUFSIZ]
puts('what is the secret password? ');
fgets(buf, BUFSIZ, stdin);
if (strcmp('secret', buf)) exit(1);

Should work as well as anything else you might code, and has the advantage of simplicity and portability.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜