password.h 2.43 KB
Newer Older
Niels Möller's avatar
Niels Möller committed
1 2 3
/* password.h
 *
 * System dependant password related functions.
4 5
 *
 * $Id$
Niels Möller's avatar
Niels Möller committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
 */

/* lsh, an implementation of the ssh protocol
 *
 * Copyright (C) 1998 Niels Mller
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef LSH_PASSWORD_H_INCLUDED
#define LSH_PASSWORD_H_INCLUDED

Niels Möller's avatar
Niels Möller committed
30
#include "lsh.h"
Niels Möller's avatar
Niels Möller committed
31

32 33
#include "alist.h"

Niels Möller's avatar
Niels Möller committed
34
#include <sys/types.h>
35
#if HAVE_UNISTD_H
Niels Möller's avatar
Niels Möller committed
36
#include <unistd.h>
37
#endif
Niels Möller's avatar
Niels Möller committed
38

39 40 41 42
#define CLASS_DECLARE
#include "password.h.x"
#undef CLASS_DECLARE

Niels Möller's avatar
Niels Möller committed
43
struct lsh_string *
Niels Möller's avatar
Niels Möller committed
44
read_password(int max_length, struct lsh_string *prompt, int free);
Niels Möller's avatar
Niels Möller committed
45

46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
/* CLASS:
   (class
     (name unix_user)
     (vars
       (uid simple uid_t)
       (gid simple gid_t)
       
       ; These strings include a terminating NUL-character, for
       ; compatibility with library and system calls.
       (name string)
       (passwd string)  ; Crypted passwd
       (home string)
       (shell string)))
       
*/

Niels Möller's avatar
Niels Möller committed
62
struct unix_user *lookup_user(struct lsh_string *name, int free);
63 64
int verify_password(struct unix_user *user,
		    struct lsh_string *password, int free);
65 66 67

struct userauth *make_password_userauth(void);

68 69 70 71 72 73 74
/* CLASS:
   (class
     (name unix_service)
     (vars
       (login method (object ssh_service) "struct unix_user *user")))
*/

75 76 77 78 79 80 81 82
#define LOGIN(s, u) ((s)->login((s), (u)))

struct userauth *make_unix_userauth(struct alist *services);

int change_uid(struct unix_user *user);
int change_dir(struct unix_user *user);

#if 0
Niels Möller's avatar
Niels Möller committed
83
struct login_method
84 85 86
{
  struct lsh_object header;

Niels Möller's avatar
Niels Möller committed
87 88 89
  struct ssh_service * (*login)(struct login_method *closure,
				struct unix_user *user,
				struct ssh_service *service);
90 91
};

Niels Möller's avatar
Niels Möller committed
92
#define LOGIN(m, u, s) ((m)->login((m), (u), (s)))
Niels Möller's avatar
Niels Möller committed
93

Niels Möller's avatar
Niels Möller committed
94 95 96
struct userauth *make_unix_userauth(struct login_method *login,
				    struct alist *services);
struct login_method *make_unix_login(void);
97
#endif
Niels Möller's avatar
Niels Möller committed
98 99

#endif /* LSH_PASSWORD_H_INCLUDED */