github.com/j8r/libcrown

Library for Unix users, groups and passwords manipulation

7 stars
1 dependent
License: ISC

Nothing has been indexed for 0.2.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.

Installation

# Add this to your shard.yml
dependencies:
  libcrown:
    github: j8r/libcrown
    version: ~> 0.2.0

Then run:

shards install

shard.yml

No shard.yml has been indexed for 0.2.0. You can read it on the repository.

Dependencies

Unknown: the shard.yml for this version has not been read yet.

README

This README is the one indexed from the repository at its latest ref, not from the tag for this version.

Libcrown

Build Status ISC

Library for Unix users, groups and passwords manipulation.

Can be used to perform actions in Crystal usually done by commands like adduser, deluser.

Warning

By essence, manipulating system users, groups and passwords is sensitive. Be careful and be sure of what you do before any action.

This library is provided "as is", with no warranties, as stated in the ISC LICENSE.

Installation

Add the dependency to your shard.yml:

dependencies:
  libcrown:
    github: j8r/libcrown

Documentation

https://j8r.github.io/libcrown

Usage

To add a new user

require "libcrown"

# Root permissions are needed
libcrown = Libcrown.new

# Add a new group
libcrown.add_group Libcrown::Group.new("new_group"), 100_u32

# Add a new user with `new_group` as its main group
new_user = Libcrown::User.new(
  name:           "new_user",
  gid:            100_u32,
  full_name:      "New Usser",
  home_directory: "/home/new_user",
  login_shell:    "/bin/sh",
)
libcrown.add_user new_user

# Save the modifications to the disk
libcrown.write

License

Copyright (c) 2018-2019 Julien Reichardt - ISC License