projects
/
paraslash.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Cosmetics.
[paraslash.git]
/
command.c
diff --git
a/command.c
b/command.c
index 319c88a6ba5f3aa7c6da1f124eb2c247e93eb2dd..fee817b005f69c7325760238725700d04046a25e 100644
(file)
--- a/
command.c
+++ b/
command.c
@@
-40,8
+40,16
@@
static unsigned char rc4_buf[2 * RC4_KEY_LEN];
extern struct misc_meta_data *mmd;
extern struct sender senders[];
extern struct misc_meta_data *mmd;
extern struct sender senders[];
-static void dummy(__a_unused int s)
-{}
+static void dummy(int s)
+{
+ /*
+ * At least on Solaris, SIGUSR1 is one-shot, i.e. the signal action is
+ * restored to the default state once the signal handler has been
+ * called.
+ */
+ if (s == SIGUSR1)
+ signal(SIGUSR1, dummy);
+}
static void mmd_dup(struct misc_meta_data *new_mmd)
{
static void mmd_dup(struct misc_meta_data *new_mmd)
{
@@
-108,7
+116,7
@@
static char *get_status(struct misc_meta_data *nmmd)
flags = vss_get_status_flags(nmmd->vss_status_flags);
if (nmmd->size) { /* parent currently has an audio file open */
localtime_r(&nmmd->mtime, &mtime_tm);
flags = vss_get_status_flags(nmmd->vss_status_flags);
if (nmmd->size) { /* parent currently has an audio file open */
localtime_r(&nmmd->mtime, &mtime_tm);
- strftime(mtime, 29, "%
a %
b %d %Y", &mtime_tm);
+ strftime(mtime, 29, "%b %d %Y", &mtime_tm);
}
gettimeofday(&now, NULL);
ret = make_message(
}
gettimeofday(&now, NULL);
ret = make_message(
@@
-118,10
+126,9
@@
static char *get_status(struct misc_meta_data *nmmd)
"%s: %s\n" /* status flags */
"%s: %li\n" /* offset */
"%s: %s\n" /* afs mode */
"%s: %s\n" /* status flags */
"%s: %li\n" /* offset */
"%s: %s\n" /* afs mode */
- "%s: %s\n" /* server uptime */
"%s: %lu.%lu\n" /* stream start */
"%s: %lu.%lu\n" /* current server time */
"%s: %lu.%lu\n" /* stream start */
"%s: %lu.%lu\n" /* current server time */
- "%s
\n
", /* afs status info */
+ "%s", /* afs status info */
status_item_list[SI_FILE_SIZE], nmmd->size / 1024,
status_item_list[SI_MTIME], mtime,
status_item_list[SI_STATUS], status,
status_item_list[SI_FILE_SIZE], nmmd->size / 1024,
status_item_list[SI_MTIME], mtime,
status_item_list[SI_STATUS], status,
@@
-130,7
+137,6
@@
static char *get_status(struct misc_meta_data *nmmd)
status_item_list[SI_OFFSET], offset,
status_item_list[SI_AFS_MODE], mmd->afs_mode_string,
status_item_list[SI_OFFSET], offset,
status_item_list[SI_AFS_MODE], mmd->afs_mode_string,
- status_item_list[SI_UPTIME], ut,
status_item_list[SI_STREAM_START],
(long unsigned)nmmd->stream_start.tv_sec,
(long unsigned)nmmd->stream_start.tv_usec,
status_item_list[SI_STREAM_START],
(long unsigned)nmmd->stream_start.tv_sec,
(long unsigned)nmmd->stream_start.tv_usec,
@@
-280,7
+286,7
@@
int com_si(int fd, int argc, __a_unused char * const * argv)
"supported senders: %s\n"
"%s",
ut, mmd->num_played,
"supported senders: %s\n"
"%s",
ut, mmd->num_played,
- getppid(),
+
(int)
getppid(),
mmd->active_connections,
mmd->num_commands,
mmd->num_connects,
mmd->active_connections,
mmd->num_commands,
mmd->num_connects,
@@
-303,7
+309,7
@@
int com_version(int fd, int argc, __a_unused char * const * argv)
return -E_COMMAND_SYNTAX;
return send_buffer(fd, VERSION_TEXT("server")
"built: " BUILD_DATE "\n"
return -E_COMMAND_SYNTAX;
return send_buffer(fd, VERSION_TEXT("server")
"built: " BUILD_DATE "\n"
-
SYSTEM
", " CC_VERSION "\n"
+
UNAME_RS
", " CC_VERSION "\n"
);
}
);
}
@@
-465,10
+471,11
@@
int com_pause(__a_unused int fd, int argc, __a_unused char * const * argv)
if (argc != 1)
return -E_COMMAND_SYNTAX;
mmd_lock();
if (argc != 1)
return -E_COMMAND_SYNTAX;
mmd_lock();
- if (!vss_paused()
)
+ if (!vss_paused()
&& !vss_stopped()) {
mmd->events++;
mmd->events++;
- mmd->new_vss_status_flags &= ~VSS_PLAYING;
- mmd->new_vss_status_flags &= ~VSS_NEXT;
+ mmd->new_vss_status_flags &= ~VSS_PLAYING;
+ mmd->new_vss_status_flags &= ~VSS_NEXT;
+ }
mmd_unlock();
return 1;
}
mmd_unlock();
return 1;
}
@@
-655,8
+662,8
@@
out:
/**
* perform user authentication and execute a command
*
/**
* perform user authentication and execute a command
*
- * \param fd
t
he file descriptor to send output to
- * \param
addr socket address info of peer
+ * \param fd
T
he file descriptor to send output to
+ * \param
peername Identifies the connecting peer.
*
* \return EXIT_SUCCESS or EXIT_FAILURE
*
*
* \return EXIT_SUCCESS or EXIT_FAILURE
*
@@
-681,7
+688,7
@@
out:
*
* \sa alarm(2), rc4(3), crypt.c, crypt.h
*/
*
* \sa alarm(2), rc4(3), crypt.c, crypt.h
*/
-int handle_connect(int fd,
struct sockaddr_in *addr
)
+int handle_connect(int fd,
const char *peername
)
{
int ret, argc, use_rc4 = 0;
char buf[4096];
{
int ret, argc, use_rc4 = 0;
char buf[4096];
@@
-697,8
+704,11
@@
int handle_connect(int fd, struct sockaddr_in *addr)
signal(SIGINT, SIG_DFL);
signal(SIGTERM, SIG_DFL);
signal(SIGHUP, SIG_DFL);
signal(SIGINT, SIG_DFL);
signal(SIGTERM, SIG_DFL);
signal(SIGHUP, SIG_DFL);
- signal(SIGUSR1, SIG_IGN);
+ /* we need a blocking fd here as recv() might return EAGAIN otherwise. */
+ ret = mark_fd_blocking(fd);
+ if (ret < 0)
+ goto err_out;
challenge_nr = random();
/* send Welcome message */
ret = send_va_buffer(fd, "This is para_server, version "
challenge_nr = random();
/* send Welcome message */
ret = send_va_buffer(fd, "This is para_server, version "
@@
-738,15
+748,15
@@
int handle_connect(int fd, struct sockaddr_in *addr)
/* We can't use send_buffer here since buf may contain null bytes */
ret = send_bin_buffer(fd,(char *) crypt_buf, numbytes);
if (ret < 0)
/* We can't use send_buffer here since buf may contain null bytes */
ret = send_bin_buffer(fd,(char *) crypt_buf, numbytes);
if (ret < 0)
- goto
err_out
;
+ goto
net_err
;
/* recv decrypted number */
ret = recv_buffer(fd, buf, sizeof(buf));
if (ret < 0)
/* recv decrypted number */
ret = recv_buffer(fd, buf, sizeof(buf));
if (ret < 0)
- goto
err_out
;
+ goto
net_err
;
numbytes = ret;
ret = -E_AUTH;
if (!numbytes)
numbytes = ret;
ret = -E_AUTH;
if (!numbytes)
- goto
err_out
;
+ goto
net_err
;
if (sscanf(buf, CHALLENGE_RESPONSE_MSG "%lu", &chall_response) < 1
|| chall_response != challenge_nr)
goto err_out;
if (sscanf(buf, CHALLENGE_RESPONSE_MSG "%lu", &chall_response) < 1
|| chall_response != challenge_nr)
goto err_out;
@@
-764,12
+774,14
@@
int handle_connect(int fd, struct sockaddr_in *addr)
numbytes = strlen(buf);
ret = send_bin_buffer(fd, buf, numbytes);
if (ret < 0)
numbytes = strlen(buf);
ret = send_bin_buffer(fd, buf, numbytes);
if (ret < 0)
- goto
err_out
;
+ goto
net_err
;
if (use_rc4)
enable_crypt(fd, rc4_recv, rc4_send, NULL);
ret = read_command(fd, &command);
if (use_rc4)
enable_crypt(fd, rc4_recv, rc4_send, NULL);
ret = read_command(fd, &command);
- if (ret
< 0
)
+ if (ret
== -E_COMMAND_SYNTAX
)
goto err_out;
goto err_out;
+ if (ret < 0)
+ goto net_err;
ret = -E_BAD_CMD;
cmd = parse_cmd(command);
if (!cmd)
ret = -E_BAD_CMD;
cmd = parse_cmd(command);
if (!cmd)
@@
-785,16
+797,16
@@
int handle_connect(int fd, struct sockaddr_in *addr)
mmd->num_commands++;
mmd_unlock();
PARA_NOTICE_LOG("calling com_%s() for %s@%s\n", cmd->name, u->name,
mmd->num_commands++;
mmd_unlock();
PARA_NOTICE_LOG("calling com_%s() for %s@%s\n", cmd->name, u->name,
-
inet_ntoa(addr->sin_addr)
);
+
peername
);
ret = cmd->handler(fd, argc, argv);
if (ret >= 0) {
ret = EXIT_SUCCESS;
goto out;
}
err_out:
ret = cmd->handler(fd, argc, argv);
if (ret >= 0) {
ret = EXIT_SUCCESS;
goto out;
}
err_out:
-
PARA_NOTICE_LOG("%s\n", PARA_STRERROR
(-ret));
- if (ret != -E_SEND && ret != -E_RECV)
-
send_va_buffer(fd, "%s\n", PARA_STRERROR
(-ret));
+
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);
ret = EXIT_FAILURE;
out:
free(command);