File: cmd-password

package info (click to toggle)
webauth 4.7.0-8
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 7,932 kB
  • sloc: ansic: 28,341; sh: 12,031; perl: 8,361; xml: 6,856; makefile: 459; php: 7
file content (33 lines) | stat: -rwxr-xr-x 931 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/perl
#
# remctl backend for testing password change via remctl.
#
# The password change call should get "password" as its only argument (the
# subcommand) and the new password on standard input.  Create a file named
# password-input and store the authenticated user and the password in that
# file.
#
# Written by Russ Allbery <eagle@eyrie.org>
# Copyright 2014
#     The Board of Trustees of the Leland Stanford Junior University
#
# See LICENSE for licensing terms.

use 5.006;
use strict;
use warnings;

# Verify that the argument is correct.
if ($ARGV[0] ne 'password') {
    die "First argument is '$ARGV[0]', not password\n";
}
if (@ARGV != 1) {
    die 'Saw ', scalar(@ARGV), " arguments instead of 1\n";
}

# Save the authenticated user and the input.
open (my $data, '>', 'password-input')
    or die "$0: cannot create password-input: $!\n";
print {$data} "$ENV{REMOTE_USER}\n";
print {$data} <STDIN>;
exit 0;