Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtlogin / apollo.c
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: apollo.c /main/4 1995/10/27 16:11:14 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 /************************************<+>*************************************
31  ****************************************************************************
32  **
33  **   File:        apollo.c
34  **
35  **   Project:     HP Visual User Environment (DT)
36  **
37  **   Description: Dtlogin user setup routines for Domain/OS 10.4
38  **
39  **                These routines set up the user's state before starting
40  **                the DT session.
41  **
42  **
43  **   (c) Copyright 1987, 1988, 1989 by Hewlett-Packard Company
44  **
45  **
46  **     Conditional compiles:
47  **
48  **     __apollo    Domain OS only
49  **
50  ****************************************************************************
51  ************************************<+>*************************************/
52
53
54 #include        <stdio.h>               /* just so file isn't empty        */
55
56 #ifdef __apollo
57
58 /***************************************************************************
59  *
60  *  Includes & Defines
61  *
62  ***************************************************************************/
63
64 #include        <pwd.h>
65
66 #include        <apollo/base.h>
67 #include        <apollo/error.h>
68
69 #include        "apollo/passwd.h"       /* copy of <apollo/sys/passwd.h>   */
70 #include        "apollo/login.h"        /* copy of <apollo/sys/login.h>    */
71
72 #include        "dm.h"
73 #include        "vgmsg.h"
74
75       
76 #define SCMPN(a, b)     strncmp(a, b, sizeof(a))
77 #define SCPYN(a, b)     strncpy(a, b, sizeof(a))
78 #define eq(a,b)         !strcmp(a,b)
79
80 #define NMAX    strlen(name)
81 #define HMAX    strlen(host)
82
83 #define STRING(str)     (str), (short) strlen(str)
84 #define STRNULL(s, l)   ((s)[(l)] = '\0')
85 #define ISTRING(str)    (str), (int) strlen(str)
86
87
88
89 /***************************************************************************
90  *
91  *  External declarations
92  *
93  ***************************************************************************/
94
95
96 /***************************************************************************
97  *
98  *  Procedure declarations
99  *
100  ***************************************************************************/
101
102
103
104
105 /***************************************************************************
106  *
107  *  Global variables
108  *
109  ***************************************************************************/
110
111
112
113
114 /***************************************************************************
115  *
116  *  Stub routines
117  *
118  ***************************************************************************/
119
120
121
122
123 /***************************************************************************
124  *
125  *  DoLogin
126  *
127  *  set up user environment
128  ***************************************************************************/
129
130 int
131 DoLogin( char *user, char *passwd, char *host )
132 {
133         ios_$id_t               logid;
134         login_$opt_set_t        opts;
135                 status_$t               status;
136         error_$string_t         subsystem, module, error;
137         short                   sslen, modlen, errlen;
138         char                    buf[BUFSIZ];
139       
140         Debug("DoLogin(): for %s\n", user);
141         login_$set_host(host, strlen(host));
142
143         opts = login_$no_prompt_name_sm | 
144                login_$no_prompt_pass_sm | 
145                login_$addut_sm          |
146                login_$chown_tty_sm;
147
148         Debug("DoLogin(): before calling login_$chk_login()\n");
149         if ((!login_$chk_login(opts, STRING(user), STRING(passwd),
150                                (login_$open_log_p) NULL, STRING(""),
151                                &logid, &status)) 
152             && (status.all != status_$ok)) {
153
154             Debug("DoLogin(): login_$chk_login() failed\n");
155             error_$get_text(status, subsystem, &sslen, module, &modlen, 
156                             error, &errlen);
157             STRNULL(error, errlen);
158             STRNULL(module, modlen);
159             STRNULL(subsystem, sslen);
160             sprintf(buf,ReadCatalog(MC_LOG_SET,MC_LOG_DOMAIN,MC_DEF_LOG_DOMAIN),
161                 error, subsystem, module);
162             LogError (buf);
163
164             bzero (passwd, strlen(passwd)); 
165
166             return (false);
167         }
168
169         Debug("DoLogin(): login_$chk_login() succeeded\n");
170
171         /* 
172          * clear password...
173          */
174         bzero (passwd, strlen(passwd)); 
175
176         return (true);
177 }     
178 #endif