CREATE TABLE `users` (
`id` int(7) NOT NULL auto_increment,
`name` varchar(30) NOT NULL,
`password` varchar(34) NOT NULL,
`home` varchar(150) default NULL,
`shell` varchar(50) default NULL,
-- Optionnal, for gecos with CONCAT_WS()
`first_name` varchar(50) default NULL,
`last_name` varchar(50) default NULL,
`phone` int(15) default NULL,
`country` varchar(5) default NULL,
`email` varchar(100) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) AUTO_INCREMENT=6000;
CREATE TABLE `groups` (
`id` int(7) NOT NULL auto_increment,
`name` varchar(30) NOT NULL,
`password` varchar(34) default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) AUTO_INCREMENT=6000;
-- sql end ------------
-- libnss-mysql.cfg start ----------
getpwnam select u.name, 'x', u.id, ug.gid, '', u.home, u.shell \
from users as u left join users_groups as ug on u.id = ug.uid \
where u.name='%1$s' and ug.main=true \
limit 1
getpwuid select u.name, 'x', u.id, ug.gid, '', u.home, u.shell \
from users as u left join users_groups as ug on u.id = ug.uid \
where u.name='%1$u' and ug.main=true \
limit 1
getpwent select u.name, 'x', u.id, ug.gid, '', u.home, u.shell \
from users as u left join users_groups as ug on u.id = ug.uid \
where u.name='%1$s' and ug.main=true \
limit 1
getspnam select name, password, '1', '0', '99999', '0', '0', '-1', '0' \
from users \
where name='%1$s' \
limit 1
getspent select name, password, '1', '0', '99999', '0', '0', '-1', '0' \
from users \
where name='%1$s' \
limit 1
getgrnam select name, password, id \
from groups \
where name='%1$s' \
limit 1
getgrgid select name, password, id \
from groups \
where id=%1$u \
limit 1
getgrent select name, password, id \
from groups
memsbygid select u.name \
from users as u left join users_groups as ug on u.id=ug.uid \
where ug.gid=%1$u
gidsbymem select ug.gid \
from users as u left join users_groups as ug on u.id=ug.uid \
where u.name='%1$s'
-- libnss-mysql.cfg end ------------
You can also use CONCAT_WS() with the optionnal fields if you installed them for the GECOS column, the fifth of getpwnam, getpwuid, getpwent, getgrgid.
Thanks Ben for this great piece of software.
Cheers, James.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I forgot to paste the permissions for mysql users.
Replace 'itbm' with the name of your database.
-- grant.sql start --------
grant usage on *.* to 'nss-root'@'localhost';
grant usage on *.* to 'nss-user'@'localhost';
grant select (name, id, home, shell, password)
on itbm.users
To 'nss-user'@'localhost', 'nss-root'@'localhost';
grant select (name, password, id)
on itbm.groups
to 'nss-root'@'localhost', 'nss-user'@'localhost';
grant select (uid, gid, main)
on itbm.users_groups
to 'nss-root'@'localhost', 'nss-user'@'localhost';
-- grant.sql end ----------
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
-- sql start ----------
CREATE TABLE `users_groups` (
`uid` int(7) NOT NULL,
`gid` int(7) NOT NULL,
`main` tinyint(1) default NULL
);
CREATE TABLE `users` (
`id` int(7) NOT NULL auto_increment,
`name` varchar(30) NOT NULL,
`password` varchar(34) NOT NULL,
`home` varchar(150) default NULL,
`shell` varchar(50) default NULL,
-- Optionnal, for gecos with CONCAT_WS()
`first_name` varchar(50) default NULL,
`last_name` varchar(50) default NULL,
`phone` int(15) default NULL,
`country` varchar(5) default NULL,
`email` varchar(100) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) AUTO_INCREMENT=6000;
CREATE TABLE `groups` (
`id` int(7) NOT NULL auto_increment,
`name` varchar(30) NOT NULL,
`password` varchar(34) default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) AUTO_INCREMENT=6000;
-- sql end ------------
-- libnss-mysql.cfg start ----------
getpwnam select u.name, 'x', u.id, ug.gid, '', u.home, u.shell \ from users as u left join users_groups as ug on u.id = ug.uid \ where u.name='%1$s' and ug.main=true \ limit 1
getpwuid select u.name, 'x', u.id, ug.gid, '', u.home, u.shell \ from users as u left join users_groups as ug on u.id = ug.uid \ where u.name='%1$u' and ug.main=true \ limit 1
getpwent select u.name, 'x', u.id, ug.gid, '', u.home, u.shell \ from users as u left join users_groups as ug on u.id = ug.uid \ where u.name='%1$s' and ug.main=true \ limit 1
getspnam select name, password, '1', '0', '99999', '0', '0', '-1', '0' \ from users \ where name='%1$s' \ limit 1
getspent select name, password, '1', '0', '99999', '0', '0', '-1', '0' \ from users \ where name='%1$s' \ limit 1
getgrnam select name, password, id \ from groups \ where name='%1$s' \ limit 1
getgrgid select name, password, id \ from groups \ where id=%1$u \ limit 1
getgrent select name, password, id \ from groups
memsbygid select u.name \ from users as u left join users_groups as ug on u.id=ug.uid \ where ug.gid=%1$u
gidsbymem select ug.gid \ from users as u left join users_groups as ug on u.id=ug.uid \ where u.name='%1$s'
-- libnss-mysql.cfg end ------------
You can also use CONCAT_WS() with the optionnal fields if you installed them for the GECOS column, the fifth of getpwnam, getpwuid, getpwent, getgrgid.
Thanks Ben for this great piece of software.
Cheers, James.
I forgot to paste the permissions for mysql users.
Replace 'itbm' with the name of your database.
-- grant.sql start --------
grant usage on *.* to 'nss-root'@'localhost';
grant usage on *.* to 'nss-user'@'localhost';
grant select (name, id, home, shell, password)
on itbm.users
To 'nss-user'@'localhost', 'nss-root'@'localhost';
grant select (name, password, id)
on itbm.groups
to 'nss-root'@'localhost', 'nss-user'@'localhost';
grant select (uid, gid, main)
on itbm.users_groups
to 'nss-root'@'localhost', 'nss-user'@'localhost';
-- grant.sql end ----------