OSX verify username and password in one line


 
Thread Tools Search this Thread
Operating Systems OS X (Apple) OSX verify username and password in one line
# 1  
Old 12-29-2012
OSX verify username and password in one line

I'm writing a script that has the need to verify the current user's username and password. I'm not entirely sure how to do this. I've read some things on "dscl" but am not sure that's the correct route for me to go.

The one condition i have is that i really need to have the verification happen in one line of code. I'm using a different scripting language (MEL) to execute the bash terminal command, so being prompted to enter a password doesn't really help me.

Appreciate any help!!Thanks!!

-drizzle

(I should mention Unix is not my native scripting language. I'm not a complete idiot when it comes to unix, but elaboration on any answers would be more than appreciated!)

*edit: I should have been clearer.. i have the username and password stored as a variable, i just need to verify that they are correct.

Last edited by TheDrizzle; 12-29-2012 at 08:55 PM..
# 2  
Old 12-29-2012
MEL used to be the maya embedded scripting language. What does that have to do with a bash terminal command? It sounds like you need the MEL syntax to execute a bash script or command.

I do not know MEL - you get to figure out how to execute something like this native UNIX statement:
Code:
/bin/bash -c '/folder/to/myscript.sh foo bar'

where foo is the valid username and bar is the valid password. And be able to see the status return code of the script a 1 (one) or a 0 (zero).

script lives in /somefolder/somewhere/you/put/it, with file permissions 755:
Code:
#!/bin/bash
trap 'exit 1' INT
echo -n 'Enter username: '
read u
echo -n 'password: '
read p
[[ "$1" = "$u"  && "$2" = "$p" ]] && exit 0 
exit 1

myscript.sh does all the stuff you cannot do in "one line", it has a status code of 0 if all is well, 1 otherwise.

Plus - as a wild guess - I believe that your question is probably ill-formed. There must be a way to run your MEL script process from bash itself under maya, maya is an executable. You are already running MEL.

You could construct your password query there, since you appear to have a hard-coded password and username anyway. Then either run or not run the entire maya/app/scripts bundle.
partial bash/Pseudocode ( I know nothing about maya)
Code:
#!/bin/bash
password=bar
username=foo

trap 'exit 1' INT
echo -n 'Enter username: '
read u
echo -n 'password: '
read p
[[ "$1" != "$username"  || "$2" != "$password" ]] && exit 1
# run maya bundle here
maya blah blah

# 3  
Old 12-29-2012
Thank you for the quick reply, I think I didn't explain myself very well.

Basically, I built a UI in Maya. Within that UI the user will enter a UserName and a Password into their appropriate fields. What I'm trying to achieve is a way verify that the user and pass entered are actually valid and not misspelled or just plain wrong.

I am using Maya's "system" function to execute unix commands from within maya. That's why a one line verification would be best.

As far as i can tell there's no way for me to answer a prompt using this method. So for example i can't enter the username and then wait for a prompt to enter the password. Whatever command i send from maya to the terminal, it has to have a return answer of some kind.

Thanks
# 4  
Old 12-30-2012
The system is designed to make this difficult, because the functionality you want would be as convenient for malicious password bruteforcing as it would be for more benign purposes. The system goes to some length to guarantee that password prompts get typed into by human beings in realtime. You may need the third-party expect brute-forcing tool to make it possible to hijack them so they aren't.

If you do get it working, it may be a severe security hole because of the way things in ps are liable to show their commandline parameters.

Last edited by Corona688; 12-30-2012 at 02:50 AM..
# 5  
Old 12-30-2012
That's a real bummer. Makes a lot of sense though I guess. Thanks for your quick reply!

-Drizzle
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Logging in with Username/Password on one line

Hello, I am currently working on a project that requires me to remote login into another UNIX system using different credentials. The problem is that progamatically I cannot simply feed the password into the UNIX system. Is there a way to feed the password within one command line statement. I... (1 Reply)
Discussion started by: myoung88
1 Replies

2. UNIX for Dummies Questions & Answers

How do you reset username/password

Picked up a 3b2 running System V. Works fine, but it requires a username and password. Is the username "root" or "sysadm"? How do I find out and how to I reset it or bypass it? Thanks. (2 Replies)
Discussion started by: TanRuNomad
2 Replies

3. Shell Programming and Scripting

Username and password

Hi I am new to using unix and am struggling with a script i am writing. What i am trying to do is get a user to enter a username, check the original file i created with username and pin to see if their is a corresponding entry. Next ask the user to enter the pin and see if this matches... (5 Replies)
Discussion started by: somersetdan
5 Replies

4. Solaris

solaris 8 reset root password from OSX

Hello, I have two old Solaris machines $ uname -a SunOS unknown 5.8 Generic_117350-39 sun4u sparc SUNW,UltraAX-e2 unfortunately, it has been so long ago that i have used these that the root password has left my head... i can log into one of the machine as a normal user, but am unable to... (4 Replies)
Discussion started by: Norman Khine
4 Replies

5. Shell Programming and Scripting

FTP command line username and password passing

Dear All, I am new to unix and I am trying to build a shell script which will connect to a different server by passing username and password from a file or command line but not manually... In short I dont want to connect to a diff server via ftp interactively. Any suggestion...looking... (8 Replies)
Discussion started by: Pratik4891
8 Replies

6. UNIX for Dummies Questions & Answers

How can i hide username/password

hi all, i run sqlplus command on unix(HP-UX) like "sqlplus username/password@serverA @deneme.sql" but when someone run "ps -ef | grep sqlplus", it can see my username and password :( How can i hide username and password. thanx. (1 Reply)
Discussion started by: temhem
1 Replies

7. OS X (Apple)

OSX asks password but i don't use a password!!

When i try to install some software OSX asks for a password but i don't use a password at all. Somebody knows a answer please??? asta (4 Replies)
Discussion started by: astapopulos
4 Replies

8. UNIX for Advanced & Expert Users

password verification verify password of a user for only first 8 characters

Helo , I m using linux pam library for user and its password authentication. I m creating new user and giving its password.I m giving password of 10 characters.now when I login in as that newly created user its ask me $ su - ram Password: You are required to change your password immediately... (12 Replies)
Discussion started by: amitpansuria
12 Replies

9. Shell Programming and Scripting

verify sudo password

edited and removed (0 Replies)
Discussion started by: mdpalow
0 Replies

10. Shell Programming and Scripting

username password in script

Can we write a script to telnet to a unix server from unix with the username and password hardcoded in the script?? something like ssh a@b -p password ??? (5 Replies)
Discussion started by: roshanjain2
5 Replies
Login or Register to Ask a Question