#include "afs.h"
#include "server.h"
#include "vss.h"
+#include "list.h"
#include "send.h"
#include "rc4.h"
#include "net.h"
#include "daemon.h"
#include "fd.h"
-#include "list.h"
#include "user_list.h"
#include "server_command_list.h"
#include "afs_command_list.h"
if (ret < 0)
goto out;
ret = 1;
- if (num == 1)
+ if (num > 0 && !--num)
goto out;
sleep(50);
if (getppid() == 1)
*/
static int check_perms(unsigned int perms, struct server_command *cmd_ptr)
{
- PARA_DEBUG_LOG("%s", "checking permissions\n");
+ PARA_DEBUG_LOG("checking permissions\n");
return (cmd_ptr->perms & perms) < cmd_ptr->perms ? -E_PERM : 0;
}
}
/**
- * perform user authentication and execute a command
- *
- * \param fd The file descriptor to send output to
- * \param peername Identifies the connecting peer.
+ * Perform user authentication and execute a command.
*
- * \return EXIT_SUCCESS or EXIT_FAILURE
+ * \param fd The file descriptor to send output to.
+ * \param peername Identifies the connecting peer.
*
* Whenever para_server accepts an incoming tcp connection on
* the port it listens on, it forks and the resulting child
*
* \sa alarm(2), rc4(3), crypt.c, crypt.h
*/
-int handle_connect(int fd, const char *peername)
+__noreturn void handle_connect(int fd, const char *peername)
{
int ret, argc, use_rc4 = 0;
char buf[4096];
PARA_NOTICE_LOG("calling com_%s() for %s@%s\n", cmd->name, u->name,
peername);
ret = cmd->handler(fd, argc, argv);
- if (ret >= 0) {
- ret = EXIT_SUCCESS;
+ if (ret >= 0)
goto out;
- }
err_out:
send_va_buffer(fd, "%s\n", para_strerror(-ret));
net_err:
PARA_NOTICE_LOG("%s\n", para_strerror(-ret));
- ret = EXIT_FAILURE;
out:
free(command);
free(argv);
mmd->events++;
mmd->active_connections--;
mmd_unlock();
- return ret;
+ exit(ret < 0? EXIT_FAILURE : EXIT_SUCCESS);
}