Closed

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

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

}

}

typo:

getent passwd 1001 (C program calls /usr/local/sbin/nssCustom.pl foobar getpwuid 1001)

also budget should bet 20-200... can't find where to edit that.

Skills: C Programming, Perl

See more: when to use freelancer, what is in c programming, what is c# programming, what is c programming, variables in programming, user testing freelancer, type of freelancer username, system x on freelancer, switch c programming, set in c, scope programming, pw freelancer, programming test questions, programming job freelancer, programming in perl, programming freelancer c++, perl get, or in c programming, one line programming job, linux programming freelancer

About the Employer:
( 0 reviews ) United States

Project ID: #4919631

1 freelancer is bidding on average $368 for this job

lepoitr

I'm interested. I'm experienced(15+) perl developer and linux administrator.

$368 USD in 3 days
(17 Reviews)
5.5