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