Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtlogin / apollo / login.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: login.h /main/3 1995/10/27 16:19:16 rswiston $ */
24 /*                                                                      *
25  * (c) Copyright 1993, 1994 Hewlett-Packard Company                     *
26  * (c) Copyright 1993, 1994 International Business Machines Corp.       *
27  * (c) Copyright 1993, 1994 Sun Microsystems, Inc.                      *
28  * (c) Copyright 1993, 1994 Novell, Inc.                                *
29  */
30 /*  LOGIN.INS.C, /us/ins, rod, 12/09/88 */
31
32 /* changes:
33     12/21/88 gilbert Modifications for C++.
34     12/09/88 betsy  add login_$logins_disabled 
35     04/19/88 betsy  cast values for login_$opt_set_t  ( to be consistent )
36     03/30/88 betsy  add login_$set_host
37     03/21/88 betsy  add options login_$addut & login_$chown_tty
38         01/04/88 brian  Fixed param decl of login_$chk_login
39         12/31/87 brian  Converted to ANSII from /us/ins/login.ins.c/6
40 */
41
42 #define login_$mod 2
43
44 #define login_$err_shut        0x07020001  /*user wants to caller to shut down*/
45 #define login_$err_exit        0x07020002  /*user wants to caller to exit*/
46 #define login_$no_room         0x07020003  /*no room for rep at open */
47 #define login_$bad_passwd      0x07020004  /*passwd check failed */
48 #define login_$inv_acct        0x07020005  /* account expired */
49 #define login_$logins_disabled 0x07020006  /* logins disabled */
50
51 #define login_$log_stream_index 4    /* 4th stream in streams array is the open log */
52
53
54 typedef void *login_$ptr;
55
56 typedef short enum { login_$read, login_$update } login_$mode_t;
57
58 typedef short enum {
59     login_$log_events,      /* log all events */
60     login_$log_inv_only,    /* log only unsuccessful attempts to log in */
61     login_$no_passwd,       /* don't require password (!) */
62     login_$no_setsid,       /* implies no_setpm, but allows set of wd/nd */
63     login_$no_setpm,        /* not done unless setsid successfully done */
64     login_$no_setwd,        /* not done if setsid attempted and failed */
65     login_$fail_ret,        /* return if failure logged */
66     login_$no_prompt_name,  /* no prompt for name */
67     login_$no_prompt_pass,  /* no prompt for password */
68     login_$preserve_sub,    /* preserve subsystem */
69     login_$leave_log_open,  /* leave log file open on return */
70     login_$addut,           /* add utmp/wtmp/lastlog entry */
71     login_$chown_tty,       /* chown the login device */
72     login_$extra14,         /* pad to 32-bit set */
73     login_$extra15, 
74     login_$extra16, 
75     login_$extra17          /* just over the border */
76 } login_$opt_t;
77
78 typedef long login_$opt_set_t;
79 #define login_$log_events_sm      ((login_$opt_set_t) (1 << (int) login_$log_events))
80 #define login_$log_inv_only_sm    ((login_$opt_set_t) (1 << (int) login_$log_inv_only))
81 #define login_$no_passwd_sm       ((login_$opt_set_t) (1 << (int) login_$no_passwd))
82 #define login_$no_setsid_sm       ((login_$opt_set_t) (1 << (int) login_$no_setsid))
83 #define login_$no_setpm_sm        ((login_$opt_set_t) (1 << (int) login_$no_setpm))
84 #define login_$no_setwd_sm        ((login_$opt_set_t) (1 << (int) login_$no_setwd))
85 #define login_$fail_ret_sm        ((login_$opt_set_t) (1 << (int) login_$fail_ret))
86 #define login_$no_prompt_name_sm  ((login_$opt_set_t) (1 << (int) login_$no_prompt_name))
87 #define login_$no_prompt_pass_sm  ((login_$opt_set_t) (1 << (int) login_$no_prompt_pass))
88 #define login_$preserve_sub_sm    ((login_$opt_set_t) (1 << (int) login_$preserve_sub))
89 #define login_$leave_log_open_sm  ((login_$opt_set_t) (1 << (int) login_$leave_log_open))
90 #define login_$addut_sm           ((login_$opt_set_t) (1 << (int) login_$addut))
91 #define login_$chown_tty_sm       ((login_$opt_set_t) (1 << (int) login_$chown_tty))
92
93 typedef char login_$string_t[256];
94 typedef ios_$id_t login_$streams_t[4];
95
96 typedef char (*login_$open_log_p)(
97                 char            * log_file,
98                 short           & log_flen,
99                 stream_$id_t    * logstr
100 );
101
102 typedef struct {
103         int                     (*help)(stream_$id_t    & stream);
104         login_$open_log_p       open_log;
105         /* A note to you:                                                     aug-87
106          These next two routines are here only for callers that cannot provide streams
107          for their i/o (i.e. the dm. It was just too hard, esp since he is 'going away'.)
108          To have them used, pass the number -2 as your first stream in login_$streams_t.
109          A bit of a hack, true, but as long as we all understand each other, it will work.
110          Login_$login promises NOT to ref these routines if you pass real streams. (Note
111          that the fillbuf stuff is gone (since changing home dir is no longer supported.)
112         */ 
113         short                   (*pread)(
114                                         stream_$id_t    & stream,
115                                         char            * inbuf,
116                                         short           & inlen,
117                                         char            * pstr,
118                                         short           & plen,
119                                         boolean         & echo,
120                                         char            * fillbuf, /* pre-fill buffer with string */
121                                         short           & fillbuflen
122                                 );
123         int                     (*pwrite)(
124                                         stream_$id_t    & stream,
125                                         char            * pstr,
126                                         short           & plen
127                                 );
128 } login_$proc_rec_t;
129
130
131 /*  Required for C++ V2.0  */
132 #ifdef  __cplusplus
133     extern "C" {
134 #endif
135
136 /* FULL_LOGIN --- performs the login function with prompting, implementing system policy,
137             setting wd, nd, pm_$sid_text, pm_$home_txt and default shell (unless 
138             already set), prints /etc/dmmsg if exists.  Supports 'shut, 'exit' and 
139             'help' and all options EXCEPT login_$no_setsid.  Takes optional strings
140             for pre-read user name [passwd]. */
141 extern boolean 
142 login_$full_login(
143         login_$opt_set_t        & opts,
144         login_$streams_t        * streams,      /* in, out, err, log_stream  */
145         char                    * login_name,   /* login string - iff login_$no_prompt_name */
146         short                   & login_nlen,
147         char                    * pass,         /* passwd string - iff login_$no_prompt_pass */
148         short                   & passlen,
149         login_$proc_rec_t       & ioprocs,      /* procedure vectors */
150         char                    * log_file,     /* used iff login_$log_events/inv in opts */
151         short                   & log_flen,
152         status_$t               * status
153 );
154
155 /* CHK_LOGIN --- performs the login function based on the strings passed in with no 
156                 prompting.  DOES NOT fully implement system policy. i.e. does nothing
157                 if passwd needs to be changed, but returns bad status if expired or
158                 invalid accounts.  Gives no error msgs. */
159 extern boolean
160 login_$chk_login (
161         login_$opt_set_t        & opts,
162         char                    * login_name,   /* login string - iff login_$no_prompt_name */
163         short                   & login_nlen,
164         char                    * pass,         /* passwd string - iff login_$no_prompt_pass */
165         short                   & passlen,
166         login_$open_log_p       & open_log,     /* used iff login_$log_events/inv in opts */
167         char                    * log_file,     /* used iff login_$log_events/inv in opts */
168         short                   & log_flen,     /* used iff login_$log_events/inv in opts */
169         ios_$id_t               * log_stream,   /* stream for open log file iff login_$leave_log_open */
170         status_$t               * status
171 );
172
173 /*-----------------------------------------------------------------------------
174   LOGIN_$SET_HOST - sets the host name to be used in the addut on a subsequent 
175                     login_$full_login or login_$chk_login call                 */
176 extern void 
177 login_$set_host(
178    char        * host_name,  /* max len is 64 */
179    int         & host_len
180 );
181
182 /* O P E N --- prepare to do login type stuff */
183 extern void
184 login_$open(
185         login_$mode_t   & lmode,
186         login_$ptr      * lptr,
187         status_$t       * st
188 );
189
190 /* S E T _ P P O -- set the PPO to operate on 
191    if ppo length is zero, use currently logged in user's PPO
192    if set_ppo not call before chpass, ckpass or chhdir called, one
193    will automatically be done (for current user)
194 */
195 extern void
196 login_$set_ppo(
197         login_$ptr      & lptr,
198         char            * ppo,
199         short           & plen,
200         status_$t       * st
201 );
202
203 /* C K P A S S -- check password 
204    checks the supplied password against that of the set PPO 
205 */        
206 extern void
207 login_$ckpass(
208         login_$ptr      & lptr,
209         char            * pass,
210         short           & plen,
211         status_$t       * st
212 );                              
213
214 /* C H P A S S --- change password in the registry */
215 extern void 
216 login_$chpass(
217         login_$ptr      & lptr,
218         char            * pass,
219         short           & plen,
220         status_$t       * st
221 );
222
223 /* C H H D I R --- change home directory in the registry */
224 extern void 
225 login_$chhdir(
226         login_$ptr      & lptr,
227         char            * hdir,
228         short           & hlen,
229         status_$t       * st
230 );
231
232 /* E R R _ C O N T E X T --- file name that had problems */
233 extern void 
234 login_$err_context(
235         login_$ptr      & lptr,
236         status_$t       * errst,
237         char            * badf,
238         short           * blen,
239         status_$t       * st
240 );
241
242 /* C L O S E --- release all acquired resources */
243     /* NOTE --- call even if open FAILS! */
244 extern void 
245 login_$close(
246         login_$ptr      & lptr,
247         status_$t       * st
248 );
249
250
251 #ifdef  __cplusplus
252     }
253 #endif
254