summaryrefslogtreecommitdiffstats
path: root/auth-skey.c
blob: 9c981ec838018ce3c4ab7099321b706f9526e5dd (plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/* $OpenBSD: auth-skey.c,v 1.23 2006/03/25 13:17:01 djm Exp $ */
/*
 * Copyright (c) 2001 Markus Friedl.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
#include "includes.h"

#ifdef SKEY

#include <skey.h>

#include "xmalloc.h"
#include "auth.h"
#include "monitor_wrap.h"

static void *
skey_init_ctx(Authctxt *authctxt)
{
	return authctxt;
}

int
skey_query(void *ctx, char **name, char **infotxt,
    u_int* numprompts, char ***prompts, u_int **echo_on)
{
	Authctxt *authctxt = ctx;
	char challenge[1024], *p;
	int len;
	struct skey skey;

	if (_compat_skeychallenge(&skey, authctxt->user, challenge,
	    sizeof(challenge)) == -1)
		return -1;

	*name  = xstrdup("");
	*infotxt  = xstrdup("");
	*numprompts = 1;
	*prompts = xcalloc(*numprompts, sizeof(char *));
	*echo_on = xcalloc(*numprompts, sizeof(u_int));

	xasprintf(*prompts, "%s%s", challenge, SKEY_PROMPT);

	return 0;
}

int
skey_respond(void *ctx, u_int numresponses, char **responses)
{
	Authctxt *authctxt = ctx;

	if (authctxt->valid &&
	    numresponses == 1 &&
	    skey_haskey(authctxt->pw->pw_name) == 0 &&
	    skey_passcheck(authctxt->pw->pw_name, responses[0]) != -1)
	    return 0;
	return -1;
}

static void
skey_free_ctx(void *ctx)
{
	/* we don't have a special context */
}

KbdintDevice skey_device = {
	"skey",
	skey_init_ctx,
	skey_query,
	skey_respond,
	skey_free_ctx
};

KbdintDevice mm_skey_device = {
	"skey",
	skey_init_ctx,
	mm_skey_query,
	mm_skey_respond,
	skey_free_ctx
};
#endif /* SKEY */
/span> ENDCODE = 26, STARTSTACK = 27, KSTKESP = 28, KSTKEIP = 29, SIGNAL = 30, BLOCKED = 31, SSIGIGNORE = 32, SIGCATCH = 33, WCHAN = 34, NSWAP = 35, CNSWAP = 36, EXIT_SIGNAL = 37, } UnsupportedProcessField; typedef enum LinuxProcessFields { CMINFLT = 11, CMAJFLT = 13, UTIME = 14, STIME = 15, CUTIME = 16, CSTIME = 17, M_SHARE = 41, M_TRS = 42, M_DRS = 43, M_LRS = 44, M_DT = 45, #ifdef HAVE_OPENVZ CTID = 100, VPID = 101, #endif #ifdef HAVE_VSERVER VXID = 102, #endif #ifdef HAVE_TASKSTATS RCHAR = 103, WCHAR = 104, SYSCR = 105, SYSCW = 106, RBYTES = 107, WBYTES = 108, CNCLWB = 109, IO_READ_RATE = 110, IO_WRITE_RATE = 111, IO_RATE = 112, #endif #ifdef HAVE_CGROUP CGROUP = 113, #endif OOM = 114, IO_PRIORITY = 115, #ifdef HAVE_DELAYACCT PERCENT_CPU_DELAY = 116, PERCENT_IO_DELAY = 117, PERCENT_SWAP_DELAY = 118, #endif LAST_PROCESSFIELD = 119, } LinuxProcessField; #include "IOPriority.h" typedef struct LinuxProcess_ { Process super; IOPriority ioPriority; unsigned long int cminflt; unsigned long int cmajflt; unsigned long long int utime; unsigned long long int stime; unsigned long long int cutime; unsigned long long int cstime; long m_share; long m_trs; long m_drs; long m_lrs; long m_dt; #ifdef HAVE_TASKSTATS unsigned long long io_rchar; unsigned long long io_wchar; unsigned long long io_syscr; unsigned long long io_syscw; unsigned long long io_read_bytes; unsigned long long io_write_bytes; unsigned long long io_cancelled_write_bytes; unsigned long long io_rate_read_time; unsigned long long io_rate_write_time; double io_rate_read_bps; double io_rate_write_bps; #endif #ifdef HAVE_OPENVZ unsigned int ctid; unsigned int vpid; #endif #ifdef HAVE_VSERVER unsigned int vxid; #endif #ifdef HAVE_CGROUP char* cgroup; #endif unsigned int oom; char* ttyDevice; #ifdef HAVE_DELAYACCT unsigned long long int delay_read_time; unsigned long long cpu_delay_total; unsigned long long blkio_delay_total; unsigned long long swapin_delay_total; float cpu_delay_percent; float blkio_delay_percent; float swapin_delay_percent; #endif } LinuxProcess; #ifndef Process_isKernelThread #define Process_isKernelThread(_process) (_process->pgrp == 0) #endif #ifndef Process_isUserlandThread #define Process_isUserlandThread(_process) (_process->pid != _process->tgid) #endif }*/ ProcessFieldData Process_fields[] = { [0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, }, [PID] = { .name = "PID", .title = " PID ", .description = "Process/thread ID", .flags = 0, }, [COMM] = { .name = "Command", .title = "Command ", .description = "Command line", .flags = 0, }, [STATE] = { .name = "STATE", .title = "S ", .description = "Process state (S sleeping, R running, D disk, Z zombie, T traced, W paging, I idle)", .flags = 0, }, [PPID] = { .name = "PPID", .title = " PPID ", .description = "Parent process ID", .flags = 0, }, [PGRP] = { .name = "PGRP", .title = " PGRP ", .description = "Process group ID", .flags = 0, }, [SESSION] = { .name = "SESSION", .title = " SID ", .description = "Process's session ID", .flags = 0, }, [TTY_NR] = { .name = "TTY_NR", .title = "TTY ", .description = "Controlling terminal", .flags = 0, }, [TPGID] = { .name = "TPGID", .title = " TPGID ", .description = "Process ID of the fg process group of the controlling terminal", .flags = 0, }, [FLAGS] = { .name = "FLAGS", .title = NULL, .description = NULL, .flags = 0, }, [MINFLT] = { .name = "MINFLT", .title = " MINFLT ", .description = "Number of minor faults which have not required loading a memory page from disk", .flags = 0, }, [CMINFLT] = { .name = "CMINFLT", .title = " CMINFLT ", .description = "Children processes' minor faults", .flags = 0, }, [MAJFLT] = { .name = "MAJFLT", .title = " MAJFLT ", .description = "Number of major faults which have required loading a memory page from disk", .flags = 0, }, [CMAJFLT] = { .name = "CMAJFLT", .title = " CMAJFLT ", .description = "Children processes' major faults", .flags = 0, }, [UTIME] = { .name = "UTIME", .title = " UTIME+ ", .description = "User CPU time - time the process spent executing in user mode", .flags = 0, }, [STIME] = { .name = "STIME", .title = " STIME+ ", .description = "System CPU time - time the kernel spent running system calls for this process", .flags = 0, }, [CUTIME] = { .name = "CUTIME", .title = " CUTIME+ ", .description = "Children processes' user CPU time", .flags = 0, }, [CSTIME] = { .name = "CSTIME", .title = " CSTIME+ ", .description = "Children processes' system CPU time", .flags = 0, }, [PRIORITY] = { .name = "PRIORITY", .title = "PRI ", .description = "Kernel's internal priority for the process", .flags = 0, }, [NICE] = { .name = "NICE", .title = " NI ", .description = "Nice value (the higher the value, the more it lets other processes take priority)", .flags = 0, }, [ITREALVALUE] = { .name = "ITREALVALUE", .title = NULL, .description = NULL, .flags = 0, }, [STARTTIME] = { .name = "STARTTIME", .title = "START ", .description = "Time the process was started", .flags = 0, }, [VSIZE] = { .name = "VSIZE", .title = NULL, .description = NULL, .flags = 0, }, [RSS] = { .name = "RSS", .title = NULL, .description = NULL, .flags = 0, }, [RLIM] = { .name = "RLIM", .title = NULL, .description = NULL, .flags = 0, }, [STARTCODE] = { .name = "STARTCODE", .title = NULL, .description = NULL, .flags = 0, }, [ENDCODE] = { .name = "ENDCODE", .title = NULL, .description = NULL, .flags = 0, }, [STARTSTACK] = { .name = "STARTSTACK", .title = NULL, .description = NULL, .flags = 0, }, [KSTKESP] = { .name = "KSTKESP", .title = NULL, .description = NULL, .flags = 0, }, [KSTKEIP] = { .name = "KSTKEIP", .title = NULL, .description = NULL, .flags = 0, }, [SIGNAL] = {