source: TI05-delivery/trunk/src/bbftp-server-3.2.0/bbftpd/bbftpd_private_user.c @ 973

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI05-delivery/trunk/src/bbftp-server-3.2.0/bbftpd/bbftpd_private_user.c@973
Revision 973, 7.0 KB checked in by spascoe, 14 years ago (diff)

Added the private authentication API extensions needed to implement
NDG security. This API is connected to empty stub functions, no useful
functionality yet. Authorisation will require a further extension later.

The code compiles. Execution yet to be tested.

Line 
1/*
2 * bbftpd/bbftpd_private_user.c
3 * Copyright (C) 1999, 2000, 2001, 2002 IN2P3, CNRS
4 * bbftp@in2p3.fr
5 * http://doc.in2p3.fr/bbftp
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20 */ 
21
22/****************************************************************************
23
24 
25 
26 bbftpd_private_user.c  v 2.1.0 2001/05/21  - Routines creation
27
28*****************************************************************************/
29#include <netinet/in.h>
30#include <utime.h>
31
32#include <bbftpd.h>
33#include <daemon_proto.h>
34#include <structures.h>
35#include <syslog.h>
36
37#include <bbftpd_private_user.h>
38
39extern char currentusername[MAXLEN] ;
40
41/*******************************************************************************
42** bbftpd_private_auth :                                                       *
43**                                                                             *
44**      Routine to do the private authentication. This routine just have to    *
45**      send or to receive private data to the bbftpd daemon. For that it will *
46**      use the two routines :                                                 *
47**          bbftpd_private_send                                                *
48**          bbftpd_private_recv                                                *
49**      The reception of the OK or BAD message will be done by the calling     *
50**      routine, so if this routine has no check to do (for example just       *
51**      sending username and password) it will just call bbftp_private_send    *
52**      twice and let the calling program check if it is OK or BAD.            *
53**                                                                             *
54**      The bbftp_private_send routine has to be called with the following     *
55**      parameters:                                                            *
56**                                                                             *
57**      int bbftpd_private_send(char *buffertosend,int buffertosendlength,     *
58**                             char *logmessage)                               *
59**          char    *buffertosend = string to be send to the daemon            *
60**          int     buffertosendlength = length of the string                  *
61**          char    *logmessage                                                *
62**                                                                             *
63**      and return 0 in case of success, -1 in case of error with logmessage   *
64**      filled                                                                 *
65**                                                                             *
66**      The bbftpd_private_recv routine has to be called with the following    *
67**      parameters:                                                            *
68**                                                                             *
69**      int bbftpd_private_recv(char *buffertorecv,int lengthtoreceive,        *
70**                             char *logmessage)                               *
71**          char    *buffertorecv = string to be send to the daemon            *
72**          int     lengthtorecv = length to be received                       *
73**          char    *logmessage                                                *
74**                                                                             *
75**      and return number of byte received in case of success, -1 in case of   *
76**      error with logmessage filled                                           *
77**      It is the duty of the programmer to take care that the buffer is large *
78**      enought                                                                *
79**                                                                             *
80**                                                                             *
81**      OUPUT variable :                                                       *
82**          logmessage :  to write the error message in case of error          *
83**                                                                             *
84**      GLOBAL VARIABLE USED :                                                 *
85**                                                                             *
86**                                                                             *
87**      RETURN:                                                                *
88**          -1  Unrecoverable error                                            *
89**           0  OK                                                             *
90**                                                                             *
91*******************************************************************************/
92
93int bbftpd_private_auth(char *logmessage) 
94{   
95  char msg[NDG_MESSAGE_LEN], logmsg[NDG_MESSAGE_LEN+64];
96  /* Send version verification message.  */
97  if (bbftpd_private_recv(msg, NDG_MESSAGE_LEN, logmessage) == -1) {
98    return -1;
99  }
100  else {
101    sprintf(logmsg, "Received auth message: %s", msg);
102    syslog(LOG_INFO, logmsg);
103  }
104
105  return 0 ; 
106}
107
108
109#ifdef NDG_AUTH
110
111/*
112 * bbftpd_private_init :
113 *
114 *     Routine to initialise private authentication.  This function will be
115 *     called before bbftpd begins listening for connections and therefore
116 *     before the fork() that occurs when a client connects.
117 *
118 *     OUTPUT variable :
119 *          logmessage :  to write the error message in case of error
120 *
121 *     RETURN:
122 *         -1  Unrecoverable error
123 *          0  OK
124 *
125 */
126
127int bbftpd_private_init(char *logmessage)
128{
129  syslog(LOG_INFO, "initialising private authentication");
130  return 0;
131}
132
133/*
134 * bbftpd_private_finalise :
135 *
136 *     Routine to clean up the private authentication infrastructure when the
137 *     daemon exits.  This function is the counterpart of bbftpd_private_init and
138 *     will be called from the daemon process during exit.  NOTE: it will not
139 *     be aware of any actions of child processes.
140 *
141 */
142
143void bbftpd_private_finalise(void)
144{
145  syslog(LOG_INFO, "finalising private authentication in server");
146  return;
147}
148
149/*
150 * bbftpd_private_auth_finalise :
151 *
152 *     Routine to clean up the private authentication infrastructure for each child.
153 *     This function is the counterpart of bbftpd_private_auth and will be called from
154 *     each child of the daemon during exit.
155 *
156 */
157
158void bbftpd_private_auth_finalise(void)
159{
160  syslog(LOG_INFO, "finalising private authentication in connection");
161  return;
162}
163
164#endif // NDG_AUTH
Note: See TracBrowser for help on using the repository browser.