项目作者: istana

项目描述 :
Replacement for old libnss-mysql as naming service library.
高级语言: C
项目地址: git://github.com/istana/libnss-maria.git
创建时间: 2015-01-07T21:31:30Z
项目社区:https://github.com/istana/libnss-maria

开源协议:GNU General Public License v3.0

下载


libnss-maria" class="reference-link"> libnss-maria

Replacement for old libnss-mysql as a naming service library for Linux.

You can store user and group information in MariaDB or MySQL database. E.g. ls then automatically shows user name from the database, getent shows users and groups.

Features

  • implements password, shadow and group getters
  • cmake build system
  • libconfig for configuration
  • uses direct queries and real_escape_string
  • uses threads.c from C11
  • requirements: Glibc 2.28 or newer, GCC 8 or newer, equivalent of Debian 10 (Buster) or newer, MySQL 5.5+/MariaDB 10.0+, mariadb-connector-c/libmysqlclient. Might work or compile on older systems, but it’s untested
  • tested systems - latest Archlinux, Debian, Fedora, Ubuntu and Ubuntu LTS
  • both unix socket and hostname + port are supported
  • accepts custom mysql client configuration
  • shouldn’t be used with SUID programs

TODO

  • deb + rpm packages
  • mysql/mariadb lib should not be linked and loaded, but separated - architecture like nss_ldapd would be nice
  • add RHEL (does not have bats) or Rockylinux/AlmaLinux
  • not sure if MySQL works correctly, the test fails on buff_test which means it does not increase buffer size for long result

Feedback is welcome.

Installation & Usage

See examples and scripts/compile_and_test.sh to see how to set it up and use.

Build && Test in Docker

docker compose up
./scripts/build-docker.sh

The result is in ./Debug/src directory.

Build && Test in Vagrant

  1. brew cask install vagrant
  2. brew cask install virtualbox
  3. vagrant plugin install vagrant-vbguest
  4. vagrant up
  5. ./scripts/build-vagrant.sh
  6. # or ./scripts/build-vagrant-release.sh

The result is in ./Debug/src or ./Release/srcdirectory.

Build && Test on a Linux system

Required libraries for building the library and test, browse docker/Dockerfile* to see required packages for other distros:

  1. apt-get install coreutils build-essential cmake libmariadb-dev libconfig-dev syslog-ng-dev bats
  2. apt-get install syslog-ng mariadb-client libconfig9 mariadb-server ruby pkg-config
  3. COMPILE_ONLY=1 ./scripts/build-debug.sh
  4. (sudo) make install
  5. or
  6. mkdir Debug
  7. cd Debug
  8. cmake ..
  9. make
  10. (sudo) make install

Set RELEASE variable to any value to build a release build.

License

Copyright (C) 2015-2024 Ivan Stana

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses.

Other Software Included

Thanks

  • @xHire for answering and not answering my infinite number of questions about C
  • and other people answering my quesions

Thanks for the inspiration and help.

Debug

https://github.com/Snaipe/Criterion/issues/206

Save this as criterion.gdb and start gdb with gdb ./yourtest -x criterion.gdb.

Then, from the gdb prompt, just call run, list children with info inferiors, switch inferiors with inferior , and debug just as usual.