All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
setPasswordnow useschpasswdfor reliable non-interactive password updates.validateUsernamenow accepts Linux login names up to 32 characters long.addSSHtoUserno longer appends duplicate keys toauthorized_keys.removeUserandaddUserToGroupnow usespawnWrapperfor consistent error handling and timeout support.- Direct
require('linux-sys-user/lib/promise')now enforces the Linux platform guard instead of bypassing it. - Documentation and GitHub Pages navigation updated to reflect the current API,
including
chpasswdand theaddUserstring shortcut.
- Non-root import path:
require('linux-user/non-root')exposes only the read-only functions that do not require root and emits no root warning. Also available asrequire('linux-user').nonRoot. - Read-only promise set via
.promise.nonRoot()and the non-root module's.promise()factory. - Optional timeout support for spawned commands (
opts.timeout) to prevent hung child processes from blocking the library.
spawnWrappernow follows the Node.js(err, result)contract: errors areErrorobjects (ornullon success), and a non-zero exit code is treated as a failure. Callbacks are now invoked at most once.getExpirationparseschage --listoutput under theClocale and is no longer order/index dependent, so it is robust against localized output.addSSHtoUsernow usesspawnwith argument arrays instead of a shellexecstring, eliminating shell-injection risk from the home directory path.- Tests now skip root-dependent cases automatically when not running as root.
addUserno longer calls its callback twice or swallows theuseradderror.addGroupnow propagates thegroupadderror instead of always fetching the group info.addSSHtoUserno longer crashes withCannot read properties of nullwhen the user does not exist; it returns anError.getExpirationreturns the error instead of throwing whenchagefails.setPasswordnow reports a failure whenpasswdexits non-zero instead of calling back with no error.removeUserandaddUserToGroupnow passError|nullinstead of the raw numeric exit code as the callback's first argument.promise()no longer hangs onvalidateUsername; it is passed through as a synchronous function.build_user_commandno longer injectsnullarguments when a flag map returnsundefined.getUsers/getGroupsno longer drop the last record when/etc/passwdor/etc/grouphas no trailing newline.- TypeScript:
selinux_useris now typed asstring(it is passed to--selinux-user <value>), andother_argsacceptsstring | string[]. - Removed dead commented-out code from
setPassword.
- Promise support via
.promise()method - TypeScript definitions in
index.d.ts - SSH key management capabilities
- User expiration management (
getExpiration,setExpiration) - Comprehensive user and group management methods
- Improved documentation structure
- Enhanced README with better examples and API documentation
- Added linting scripts to package.json
- Improved package.json with additional metadata
- Fixed
Array.isArrayusage in user.js (was incorrectly usingArrays.isArray) - Added missing "use strict" to lib/promise.js
- Resolved JSHint linting errors
- Improved input validation
- Better error handling to prevent information disclosure
- Basic user and group management functionality
- SSH key verification and management
- User expiration handling
- User creation and removal
- Group management
- User information retrieval
- Password management
- SSH key management