Closed

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

This project received 3 bids from talented freelancers with an average bid price of $223 USD.

Get free quotes for a project like this
Employer working
Skills Required
Project Budget
$10 - $30 USD
Total Bids
3
Project Description

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/[url removed, login to view] has 2 configuration variables and looks like this:

# config script for libnss-nsscustom
environment: foobar
script: /usr/local/sbin/[url removed, login to view]

Also /etc/[url removed, login to view] looks like this for passwd:

passwd: compat nsscustom


Within the C program the [url removed, login to view] script is called with the first argument being whatever is set as environment in /etc/[url removed, login to view] (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/[url removed, login to view] foobar getpwent)
-> should get all system users (because compat is first in [url removed, login to view]) and return all user pw entries from the perl scipt

getent passwd jdoe (C program calls /usr/local/sbin/[url removed, login to view] foobar getpwnam jdoe)
-> should get all system users (because compat is first in [url removed, login to view]) and return the pw entry for username jdoe

getent passwd 1001 (C program calls /usr/local/sbin/[url removed, login to view] foobar getpwnam 1001)
-> should get all system users (because compat is first in [url removed, login to view]) and return the pw entry for uid 1001


simple hacked script to use for testing /usr/local/sbin/[url removed, login to view]:
#!/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

}

}

Looking to make some money?

  • Set your budget and the timeframe
  • Outline your proposal
  • Get paid for your work

Hire Freelancers who also bid on this project

    • Forbes
    • The New York Times
    • Time
    • Wall Street Journal
    • Times Online