Find Jobs
Hire Freelancers

custom NSS plugin written in C to call perl script for passwd listing

$10-30 USD

Closed
Posted over 10 years ago

$10-30 USD

Paid on delivery
The ideal freelancer for this job has a deep understanding of Linux, shared libraries, C programming, Name Service Switch. It shouldn't take someone who knows what they are doing a couple of hours to complete. Must be developed on or for 64bit Debian Wheezy 7.0. Delivered files to include "Makefile, README, nss-custom.c" and any custom header files. Please ask questions if you are interested. The scope of this plugin may increase in the future. I need a NSS plugin like libnss-mysql-ng, libnss-extrausers, etc. When NSS is called, it must be able to run a perl script to return passwd style entries. Only 3 NSS calls need to be available: getpwnam, getpwuid, getpwent. Assume the perl script to be called is /usr/local/sbin/nssCustom.pl. A config script to be read by the C program /etc/[login to view URL] has 2 configuration variables and looks like this: # config script for libnss-nsscustom environment: foobar script: /usr/local/sbin/[login to view URL] Also /etc/[login to view URL] looks like this for passwd: passwd: compat nsscustom Within the C program the [login to view URL] script is called with the first argument being whatever is set as environment in /etc/[login to view URL] (i.e. foobar). The second arguement to the perl script is the type of NSS call (one of getpwent, getpwnam, or getpwuid). The third argument to the perl script should be the username OR uid for getpwnam and getpwuid respectively. (There will be no 3rd arguement for getpwent and the perl script will return the whole list) using getent to test should look like this: getent passwd (C program calls /usr/local/sbin/[login to view URL] foobar getpwent) -> should get all system users (because compat is first in [login to view URL]) and return all user pw entries from the perl scipt getent passwd jdoe (C program calls /usr/local/sbin/[login to view URL] foobar getpwnam jdoe) -> should get all system users (because compat is first in [login to view URL]) and return the pw entry for username jdoe getent passwd 1001 (C program calls /usr/local/sbin/[login to view URL] foobar getpwnam 1001) -> should get all system users (because compat is first in [login to view URL]) and return the pw entry for uid 1001 simple hacked script to use for testing /usr/local/sbin/[login to view URL]: #!/usr/bin/perl use strict; if ( $#ARGV < 1 ){ exit; } my $users='bingobill:x:30014:666:Bingo Bill:/home/:/bin/bash yepyepyep:x:30015:666:yep yepyep:/home/:/bin/bash aasdf:x:30016:666:asdf asdf:/home/:/bin/bash tloki:x:30018:666:thor loki:/home/:/bin/bash '; if ( "$ARGV[0]" eq "foobar" ) { if ( "$ARGV[1]" eq "getpwent" ) { print "$users"; } elsif ( $ARGV[1] eq "getpwnam" ) { my @lines = split /\n/, $users; foreach my $line (@lines) { my @fields = split ":", $line; if ( "$fields[0]" eq "$ARGV[2]" ){ print $line, "\n"; } } } elsif ( $ARGV[1] eq "getpwuid" ) { my @lines = split /\n/, $users; foreach my $line (@lines) { my @fields = split ":", $line; if ( "$fields[2]" eq "$ARGV[2]" ){ print $line, "\n"; } } }else{ # do nothing for now } }
Project ID: 4919631

About the project

1 proposal
Remote project
Active 10 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
1 freelancer is bidding on average $368 USD for this job
User Avatar
I'm interested. I'm experienced(15+) perl developer and linux administrator.
$368 USD in 3 days
4.8 (17 reviews)
5.5
5.5

About the client

Flag of UNITED STATES
United States
0.0
0
Member since Sep 11, 2013

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.