Skip to content

Commit

Permalink
#1: fix the password field in user/group info (it is "passwd", not "p…
Browse files Browse the repository at this point in the history
…assword")
  • Loading branch information
vasa-c committed Jan 20, 2024
1 parent bd2e6e7 commit 594d3ab
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
## Dev

* #1: fix the password field in user/group info (it is "passwd", not "password")

## 0.1.2 (20.01.2023)

* Support PHP 8.3 (test in GitHub action)
Expand Down
4 changes: 2 additions & 2 deletions src/PosixGroupInfo.php
Expand Up @@ -10,7 +10,7 @@ class PosixGroupInfo
public readonly string $name;

/** The group password in an encrypted format (just asterisk may be used) */
public readonly string $password;
public readonly string $passwd;

/** The group ID */
public readonly int $gid;
Expand All @@ -21,7 +21,7 @@ class PosixGroupInfo
public function __construct(public readonly array $data)
{
$this->name = (string)($data['name'] ?? '');
$this->password = (string)($data['password'] ?? '');
$this->passwd = (string)($data['passwd'] ?? '');
$this->gid = (int)($data['gid'] ?? 0);
$this->members = $data['members'] ?? [];
}
Expand Down
4 changes: 2 additions & 2 deletions src/PosixUserInfo.php
Expand Up @@ -10,7 +10,7 @@ class PosixUserInfo
public readonly string $name;

/** The password in an encrypted format (just asterisk may be used) */
public readonly string $password;
public readonly string $passwd;

/** The user ID */
public readonly int $uid;
Expand All @@ -29,7 +29,7 @@ class PosixUserInfo

public function __construct(public readonly array $data)
{
foreach (['name', 'password', 'gecos', 'dir', 'shell'] as $k) {
foreach (['name', 'passwd', 'gecos', 'dir', 'shell'] as $k) {
$this->$k = (string)($data[$k] ?? '');
}
foreach (['uid', 'gid'] as $k) {
Expand Down
2 changes: 2 additions & 0 deletions tests/RealPosixTest.php
Expand Up @@ -106,6 +106,7 @@ public function testGetpwuid(): void
$this->assertSame('/home/tester', $info->dir);
$data = posix_getpwuid(1735) ?: null;
$this->assertSame($data['shell'] ?? null, $info->shell);
$this->assertSame(posix_getpwuid(1735)['passwd'] ?? null, $info->passwd);
$this->assertNull($this->posix->getpwuid(1801));
}

Expand All @@ -125,6 +126,7 @@ public function testGetgrgid(): void
$this->assertSame([
'axy_tester',
], $info->members);
$this->assertSame(posix_getgrgid(1234)['passwd'] ?? null, $info->passwd);
$this->assertNull($this->posix->getgrgid(2345));
}

Expand Down

0 comments on commit 594d3ab

Please sign in to comment.