Hiding Keyboard Input From the Screen

For my current job I'm in charge of writing a script that requires a person to input their password and me being the semi-security conscious individual that I am knew that regular input for a script like this would be bad, as that would allow for over the shoulder (literally) view of someone's password. This is just unacceptable.

To solve this problem I hit the internets for a way to hide user input in Perl script. And in my travels I came across this old PERL FAQ site. I decided to try out the code and update it, throw it into a little dummy script. This is what I got (minus the dummy script):

  1. sub get_password
  2. {
  3. print "enter your password: ";
  4. system("stty -echo");
  5. chop(my $password=<>);
  6. print "\n";
  7. system("stty echo");
  8.  
  9. return $password;
  10. }

Saved it, ran it, and Holy Missing Characters Batman, it worked. So just as a mental exercise, I wanted to see if I could get it to emulate the password request when you run sudo, and I wrote this up in Python (because I need the practice):

  1. #!/usr/bin/python
  2.  
  3. import os
  4. import getpass
  5.  
  6. def get_password():
  7. #print "Please enter your password:"
  8. os.system("stty -echo")
  9. password = raw_input( getpass.getuser() + "'s password")
  10. os.system("stty echo")
  11. print "\n"
  12.  
  13. return password
  14.  
  15. def main():
  16. local_password = get_password()
  17. print local_password
  18.  
  19. main()

And again... it worked. Of course I finally realized that the reason why it worked is because of the line "stty -echo". Taking that I typed it into a standard terminal and after hitting enter the results were the same. My terminal functioned normally, but without showing me the characters I was typing. After returning my terminal back to normal I decided to read a little more about stty. After digging through the man page for a little while I came across this argument which is an alias for echo:

[-]crterase
echo erase characters as backspace-space-backspace

Thus the reason why I couldn't see anything change is because my terminal is treating all characters I type on the screen as a three part sequence of non alphanumeric characters. Although I find this a little odd; I have to just go with the words of Bugs Bunny on this one, “I don't ask questions. I just have fun.”

Getting the eeepc synaptic pad to work with Fedora 12


Of all the how to's I've posted here over the last half year, this has to be one of the easiest. But when I tried to figure this out on my own it took a little bit of digging. So for the benefits of everyone else on the interwebs here is a one stop shop for getting your synaptic pad to work for your EEE-pc with Fedora 12.

Things you'll need:

    - an eeepc (I have a 1000, but I'm sure any will work)

    - Fedora 12 installed on said netbook

    - sudo access

    - a comfortable editor

    - you might also need to have xorg-x11-drv-synaptics installed
    (and if you don't at least now you know what to look for)

I've found that xorg.conf for fedora 12 is not included with the default install of fedora 12. Thus we need to get it; so while as root (or with sudo) type:
Xorg -configure :1

After doing this you should now have an xorg.conf file in /etc/X11. The second part is to now put a little extra configuration into the xorg.conf file. Now using your favorite editor paste the following stuff into the file. I have placed mine beneath the mouse section.

Section "InputDevice"
Identifier "Synaptics"
Driver "synaptics"
Option "Device" "/dev/input/mice"
Option "Protocol" "auto-dev"
Option "Emulate3Buttons" "yes"
Option "SendCoreEvents" "true"
Option "TapButton1" "1"
Option "TapButton2" "2"
EndSection

And for the last step, in the "ServerLayout" section we need to change this line:
InputDevice "Mouse0" "CorePointer"
to this line:
InputDevice "Synaptics" "CorePointer"

Save the changes, restart X (logging out and back in works well), and now you can single and double finger taps working with ease.I

Interview question: Recreate groups

I was in an interview and another interview walked in and said “Hi, do you know the groups tool in unix?” At which point i said “Yes”. At which point the interview hands me a whiteboard marker and says “Great. Write it”. And after a couple of minutes of thinking about how to do it, I wrote it down.

Now, I didn't end up doing it on a whiteboard, I did it on a piece of paper I had, which I kept, but unfortunately I have not beed able to scan it for everyone's reading enjoyment. But I'll do that in the future.

So once I got home after the interview, I took the algorithm, and applied proper PERL syntax. And here is the code:

  1. #!/usr/bin/perl
  2. #######################################################################
  3. # Created By: Bryce Verdier
  4. # on 1/19/10
  5. # Function: rework the output of the unix groups command
  6. # NOTE: FOR USE ON UNIX MACHINES!
  7. #######################################################################
  8. use warnings;
  9. use strict;
  10. use Getopt::Std;
  11.  
  12. our($opt_u);
  13. getopts('u:');
  14.  
  15. #Get the results from /etc/groups
  16. my $groups= `grep -w $opt_u /etc/group`;
  17.  
  18. #split it into an array for per line processing
  19. my @split_groups= split(/\n/, $groups);
  20.  
  21. #output the username we're looking for ( to emulate groups better)
  22. print ("$opt_u : ");
  23.  
  24. #where all the magic really happens
  25. #split the array again, and output the first part of the split, as based
  26. #on the strcuture of the /etc/groups file
  27. foreach (@split_groups){
  28. my @temp_split= split(/:/, $_);
  29. print ("$temp_split[0] ");
  30. }
  31.  
  32. #clean up
  33. print ("\n");

So after writing the code above originally, the interviewer looks things over and asks me a couple of questions. I don't remember all of them, the only one I can remember now ( almost two weeks later ) is below:

“Why are you using calling out instead of using a system call?”
After looking around, PERL's systems calls abilities are fairly minimal. I could open a file, and parse through it. But I figured why not save myself some of the work and use the tools in the shell to ease my work.

Regardless, if you are in preparing for an interview maybe this might give you a leg up. Or at least now other interviewers will have to start using a different question.

Examples of how NOT to get a job

In my search for my first job after graduating college, I applied to any job that I was remotely capable of doing, whether because I'd done the job in the past, or the skill set sounded very similar to what I was doing at PSU. And for all of December I was applying for jobs and not getting any kind of response for my efforts. So like any human being I became frustrated, Probably more so than I should have been, but regardless, I was frustrated.

So when applying for jobs, I let that frustration out in some of my online application questions.

Do you consider yourself an expert in Linux?
“No. Even though I've been playing with it for over ten years and I am consonantly being challenged by it. All the new features that come out with each kernel version just keep things new and interesting. Linux itself is a moving target, and I feel the only people that can call themselves linux experts are the kernel developers. Everyone else is intermediate, including me.”

And of course this little nugget of pure angst:

Please read the job description below and tell us why you are a great fit for this position.
“Although I am a recent college graduate. And I know that in this bad economy that there are better qualified people for this job I can offer a couple of things that they can't. Because the other people might be better qualified, they will also be better qualified for other jobs once the job market improves, thus anyone you hire will probably leave sooner as opposed to later. I on the other hand have a lot of growing to do, and finding an environment that allows me to do such would be beneficial to everyone. I can attain the same level of skill as these other candidates, but I will also do it for cheaper ( as I have little experience now) and will probably stay longer because I need to build up the time to build up the experience.”

Both of these questions came from two different job opportunities, and I'm sure you are just as surprised as I am to hear that neither of these companies have contacted me. Which is kind of sad in a way because if one of them did, I would know that THAT company is one worth working and toiling for because it at least has some semblance of a sense of humor. Alas, no love for the little angry wanna-be worker bee.

On the positive side, I have received a job offer from one company. So the hard work is done. I'm going to ask for some time to finish up what current interviews I have left, and see if any more job offers roll in before deciding which job to take.

UPDATE: Never tell the CEO of a social networking company that social-networking is "nothing more than self-aggrandizement and is just a fad".

Syndicate content