Merge pull request #444 from proski/trivial

Simple changes, mostly log messages and documentation
This commit is contained in:
metalefty 2016-10-20 15:52:25 +09:00 committed by GitHub
commit 0c4c52878a
32 changed files with 89 additions and 123 deletions

View File

@ -2,7 +2,7 @@ ACLOCAL_AMFLAGS = -I m4
AM_DISTCHECK_CONFIGURE_FLAGS = --without-systemdsystemunitdir
EXTRA_DIST = bootstrap COPYING coding_style.md design.txt faq-compile.txt \
faq-general.txt file-loc.txt install.txt m4 prog_std.txt readme.txt
faq-general.txt file-loc.txt install.txt m4 readme.txt
if XRDP_NEUTRINORDP
NEUTRINORDPDIR = neutrinordp

View File

@ -15,6 +15,13 @@ Here is how we run the astyle command:
This coding style is a work in progress and is still evolving.
Language Standard
-----------------
Try to make all code compile with both C and C++ compiler. C++ is more
strict, which makes the code safer.
Indentation
-----------
@ -32,7 +39,7 @@ Indentation
Line wrapping
-------------
* Keep lines shorter than 80 chars
* Keep lines not longer than 80 chars
* Align wrapped argument to the first argument
@ -46,9 +53,11 @@ Variable names
* Use lowercase with underscores as needed
* Don't use camelCase
* Preprocessor constants should be uppercase
#define BUF_SIZE 1024
int fd;
int bytes_in_stream;
@ -193,3 +202,9 @@ Braces
default:
printf("bad cmd\n");
}
Comments
--------
Use /* */ for comments
Don't use //

View File

@ -82,7 +82,7 @@ list_add_item(struct list *self, tbus item)
/*****************************************************************************/
tbus APP_CC
list_get_item(struct list *self, int index)
list_get_item(const struct list *self, int index)
{
if (index < 0 || index >= self->count)
{

View File

@ -40,7 +40,7 @@ list_delete(struct list* self);
void APP_CC
list_add_item(struct list* self, tintptr item);
tintptr APP_CC
list_get_item(struct list* self, int index);
list_get_item(const struct list *self, int index);
void APP_CC
list_clear(struct list* self);
int APP_CC

View File

@ -222,7 +222,7 @@ internal_log_end(struct log_config *l_cfg)
* @return
*/
enum logLevels DEFAULT_CC
internal_log_text2level(char *buf)
internal_log_text2level(const char *buf)
{
if (0 == g_strcasecmp(buf, "0") ||
0 == g_strcasecmp(buf, "core"))

View File

@ -113,7 +113,7 @@ internal_log_lvl2str(const enum logLevels lvl, char *str);
*
*/
enum logLevels DEFAULT_CC
internal_log_text2level(char *s);
internal_log_text2level(const char *s);
/**
* A function that init our struct that holds all state and
@ -173,16 +173,6 @@ log_end(void);
enum logReturns DEFAULT_CC
log_message(const enum logLevels lvl, const char *msg, ...) printflike(2, 3);
/**
*
* @brief Reads configuration
* @param s translates the strings "1", "true" and "yes" in 1 (true) and
* other strings in 0
* @return 0 on success, 1 on failure
*
*/
int APP_CC text2bool(char *s);
/**
* This function returns the configured file name for the logfile
* @param replybuf the buffer where the reply is stored

View File

@ -264,7 +264,7 @@ g_write(const char *format, ...)
/*****************************************************************************/
/* produce a hex dump */
void APP_CC
g_hexdump(char *p, int len)
g_hexdump(const char *p, int len)
{
unsigned char *line;
int i;
@ -439,7 +439,7 @@ g_tcp_socket(void)
if (setsockopt(rv, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&option_value,
option_len) < 0)
{
log_message(LOG_LEVEL_ERROR, "g_tcp_socket: setsockopt() failed\n");
log_message(LOG_LEVEL_ERROR, "g_tcp_socket: setsockopt() failed");
}
}
}
@ -455,7 +455,7 @@ g_tcp_socket(void)
if (setsockopt(rv, SOL_SOCKET, SO_REUSEADDR, (char *)&option_value,
option_len) < 0)
{
log_message(LOG_LEVEL_ERROR, "g_tcp_socket: setsockopt() failed\n");
log_message(LOG_LEVEL_ERROR, "g_tcp_socket: setsockopt() failed");
}
}
}
@ -472,7 +472,7 @@ g_tcp_socket(void)
if (setsockopt(rv, SOL_SOCKET, SO_SNDBUF, (char *)&option_value,
option_len) < 0)
{
log_message(LOG_LEVEL_ERROR, "g_tcp_socket: setsockopt() failed\n");
log_message(LOG_LEVEL_ERROR, "g_tcp_socket: setsockopt() failed");
}
}
}
@ -846,7 +846,7 @@ g_sck_set_non_blocking(int sck)
i = i | O_NONBLOCK;
if (fcntl(sck, F_SETFL, i) < 0)
{
log_message(LOG_LEVEL_ERROR, "g_sck_set_non_blocking: fcntl() failed\n");
log_message(LOG_LEVEL_ERROR, "g_sck_set_non_blocking: fcntl() failed");
}
#endif
return 0;
@ -1342,7 +1342,7 @@ g_set_nonblock(int fd)
/*****************************************************************************/
/* returns 0 on error */
tintptr APP_CC
g_create_wait_obj(char *name)
g_create_wait_obj(const char *name)
{
#ifdef _WIN32
tintptr obj;

View File

@ -55,7 +55,7 @@ int DEFAULT_CC g_snprintf(char* dest, int len, const char* format, ...) \
printflike(3, 4);
void DEFAULT_CC g_writeln(const char* format, ...) printflike(1, 2);
void DEFAULT_CC g_write(const char* format, ...) printflike(1, 2);
void APP_CC g_hexdump(char* p, int len);
void APP_CC g_hexdump(const char *p, int len);
void APP_CC g_memset(void* ptr, int val, int size);
void APP_CC g_memcpy(void* d_ptr, const void* s_ptr, int size);
int APP_CC g_getchar(void);
@ -88,7 +88,7 @@ int APP_CC g_sck_can_recv(int sck, int millis);
int APP_CC g_sck_select(int sck1, int sck2);
void APP_CC g_write_ip_address(int rcv_sck, char* ip_address, int bytes);
void APP_CC g_sleep(int msecs);
tintptr APP_CC g_create_wait_obj(char* name);
tintptr APP_CC g_create_wait_obj(const char *name);
tintptr APP_CC g_create_wait_obj_from_socket(tintptr socket, int write);
void APP_CC g_delete_wait_obj_from_socket(tintptr wait_obj);
int APP_CC g_set_wait_obj(tintptr obj);

View File

@ -197,8 +197,8 @@ xrdp_rdp_read_config(struct xrdp_client_info *client_info)
/* default certificate path */
g_snprintf(client_info->certificate, 1023, "%s/cert.pem", XRDP_CFG_PATH);
log_message(LOG_LEVEL_INFO,
"Missing definition of X.509 certificate, use "
"default instead: %s", client_info->certificate);
"Using default X.509 certificate: %s",
client_info->certificate);
}
else if (value[0] != '/')
@ -206,7 +206,7 @@ xrdp_rdp_read_config(struct xrdp_client_info *client_info)
/* default certificate path */
g_snprintf(client_info->certificate, 1023, "%s/cert.pem", XRDP_CFG_PATH);
log_message(LOG_LEVEL_WARNING,
"No absolute path to X.509 certificate, use "
"X.509 certificate should use absolute path, using "
"default instead: %s", client_info->certificate);
}
else
@ -222,16 +222,15 @@ xrdp_rdp_read_config(struct xrdp_client_info *client_info)
{
/* default key_file path */
g_snprintf(client_info->key_file, 1023, "%s/key.pem", XRDP_CFG_PATH);
log_message(LOG_LEVEL_INFO,
"Missing definition of X.509 key file, use "
"default instead: %s", client_info->key_file);
log_message(LOG_LEVEL_INFO, "Using default X.509 key file: %s",
client_info->key_file);
}
else if (value[0] != '/')
{
/* default key_file path */
g_snprintf(client_info->key_file, 1023, "%s/key.pem", XRDP_CFG_PATH);
log_message(LOG_LEVEL_WARNING,
"No absolute path to X.509 key file, use"
"X.509 key file should use absolute path, using "
"default instead: %s", client_info->key_file);
}
else

View File

@ -1,41 +0,0 @@
This is an attempt to explain my odd programming standard used for this project.
Not to defend any of these but it's my default standard and it makes it easy
for me to read code.
Some files break these rules, they will be updated eventually.
try to make any file compile with c++ compilers
always put one var on a line by itself
char* pvar;
char text[256];
not
char *pvar, text[256];
function calls look like this
foo(a, b, c);
not
foo ( a, b, c );
while, if, and case statements look like
while (i != 0)
not
while(i != 0)
for comments, always use /* */, not //
defines should always be uppercase
don't use tabs, use spaces
no line should exceed 80 chars
always use {} in if and while, even if it's only one line
while (p != 0)
{
p = p->next;
}
not
while (p != 0)
p = p->next;

View File

@ -21,7 +21,7 @@ xup is a module used to connect to an rdp specific X11 server
Xserver is the files needed to build an rdp specific X11 server
COPYING is the license file
design.txt is an attempt to explain the project design
prog_std.txt is an attempt to explain the programming standard used
coding_style.md describes the coding style for the project
since version 0.5.0 we switch to autotools to build xrdp

View File

@ -30,7 +30,7 @@ extern struct config_sesman *g_cfg; /* in sesman.c */
/******************************************************************************/
int DEFAULT_CC
access_login_allowed(char *user)
access_login_allowed(const char *user)
{
int gid;
int ok;
@ -79,7 +79,7 @@ access_login_allowed(char *user)
/******************************************************************************/
int DEFAULT_CC
access_login_mng_allowed(char *user)
access_login_mng_allowed(const char *user)
{
int gid;
int ok;

View File

@ -35,7 +35,7 @@
*
*/
int DEFAULT_CC
access_login_allowed(char* user);
access_login_allowed(const char *user);
/**
*
@ -45,6 +45,6 @@ access_login_allowed(char* user);
*
*/
int DEFAULT_CC
access_login_mng_allowed(char* user);
access_login_mng_allowed(const char *user);
#endif

View File

@ -32,11 +32,11 @@
* @brief Validates user's password
* @param user user's login name
* @param pass user's password
* @return 0 on success, 1 on failure
* @return non-zero handle on success, 0 on failure
*
*/
long DEFAULT_CC
auth_userpass(char* user, char* pass, int *errorcode);
auth_userpass(const char *user, const char *pass, int *errorcode);
/**
*
@ -94,7 +94,7 @@ auth_set_env(long in_val);
*
*/
int DEFAULT_CC
auth_check_pwd_chg(char* user);
auth_check_pwd_chg(const char *user);
/**
*
@ -104,6 +104,6 @@ auth_check_pwd_chg(char* user);
*
*/
int DEFAULT_CC
auth_change_pwd(char* user, char* newpwd);
auth_change_pwd(const char *user, const char *newpwd);
#endif

View File

@ -453,7 +453,7 @@ clipboard_send_file_data(int streamId, int lindex,
if (g_file_seek(fd, nPositionLow) < 0)
{
log_message(LOG_LEVEL_ERROR, "clipboard_send_file_data: seek error "
"in file: %s\n", full_fn);
"in file: %s", full_fn);
g_file_close(fd);
return 1;
}

View File

@ -235,21 +235,21 @@ fifo_remove(FIFO* fp)
void*
fifo_peek(FIFO* fp)
{
log_debug_high("entered\n");
log_debug_high("entered");
if (!fp)
{
log_debug_high("FIFO is null\n");
log_debug_high("FIFO is null");
return 0;
}
if (fp->rd_ptr == fp->wr_ptr)
{
log_debug_high("FIFO is empty\n");
log_debug_high("FIFO is empty");
return 0;
}
log_debug_low("peeking data at index %d\n", fp->rd_ptr);
log_debug_low("peeking data at index %d", fp->rd_ptr);
return (void *) fp->user_data[fp->rd_ptr];
}

View File

@ -382,7 +382,7 @@ config_read_rdp_params(int file, struct config_sesman *cs, struct list *param_n,
list_add_item(cs->rdp_params, (long)g_strdup((char *)list_get_item(param_v, i)));
}
/* printing security config */
/* printing X11rdp parameters */
g_printf("X11rdp parameters:\r\n");
for (i = 0; i < cs->rdp_params->count; i++)
@ -413,7 +413,7 @@ config_read_xorg_params(int file, struct config_sesman *cs,
(long) g_strdup((char *) list_get_item(param_v, i)));
}
/* printing security config */
/* printing XOrg parameters */
g_printf("XOrg parameters:\r\n");
for (i = 0; i < cs->xorg_params->count; i++)
@ -444,7 +444,7 @@ config_read_vnc_params(int file, struct config_sesman *cs, struct list *param_n,
list_add_item(cs->vnc_params, (long)g_strdup((char *)list_get_item(param_v, i)));
}
/* printing security config */
/* printing Xvnc parameters */
g_printf("Xvnc parameters:\r\n");
for (i = 0; i < cs->vnc_params->count; i++)
@ -478,7 +478,7 @@ config_read_session_variables(int file, struct config_sesman *cs,
(tintptr) g_strdup((char *) list_get_item(param_v, i)));
}
/* printing security config */
/* printing session variables */
g_writeln("%s parameters:", SESMAN_CFG_SESSION_VARIABLES);
for (i = 0; i < cs->session_variables1->count; i++)

View File

@ -34,7 +34,7 @@ extern struct config_sesman *g_cfg; /* in sesman.c */
/******************************************************************************/
int DEFAULT_CC
env_check_password_file(char *filename, char *passwd)
env_check_password_file(const char *filename, const char *passwd)
{
char encryptedPasswd[16];
char key[24];
@ -83,8 +83,8 @@ env_check_password_file(char *filename, char *passwd)
/******************************************************************************/
/* its the responsibility of the caller to free passwd_file */
int DEFAULT_CC
env_set_user(char *username, char **passwd_file, int display,
struct list *env_names, struct list* env_values)
env_set_user(const char *username, char **passwd_file, int display,
const struct list *env_names, const struct list *env_values)
{
int error;
int pw_uid;

View File

@ -38,7 +38,7 @@
*
*/
int DEFAULT_CC
env_check_password_file(char* filename, char* password);
env_check_password_file(const char *filename, const char *password);
/**
*
@ -50,7 +50,7 @@ env_check_password_file(char* filename, char* password);
*
*/
int DEFAULT_CC
env_set_user(char* username, char** passwd_file, int display,
struct list *env_names, struct list* env_values);
env_set_user(const char *username, char **passwd_file, int display,
const struct list *env_names, const struct list *env_values);
#endif

View File

@ -37,7 +37,7 @@ scp_connection_create(int sck)
if (0 == conn)
{
log_message(LOG_LEVEL_WARNING, "[connection:%d] connection create: malloc error", __LINE__);
log_message(LOG_LEVEL_ERROR, "[connection:%d] connection create: malloc error", __LINE__);
return 0;
}

View File

@ -42,7 +42,7 @@ scp_session_create()
if (0 == s)
{
log_message(LOG_LEVEL_WARNING, "[session:%d] session create: malloc error", __LINE__);
log_message(LOG_LEVEL_ERROR, "[session:%d] session create: malloc error", __LINE__);
return 0;
}

View File

@ -54,12 +54,12 @@ scp_process_start(void *sck)
if (sdata->version == 0)
{
/* starts processing an scp v0 connection */
LOG_DBG("accept ok, go on with scp v0\n", 0);
LOG_DBG("accept ok, go on with scp v0", 0);
scp_v0_process(&scon, sdata);
}
else
{
LOG_DBG("accept ok, go on with scp v1\n", 0);
LOG_DBG("accept ok, go on with scp v1", 0);
/*LOG_DBG("user: %s\npass: %s",sdata->username, sdata->password);*/
scp_v1_process(&scon, sdata);
}

View File

@ -77,7 +77,8 @@ dumpItemsToString(struct list *self, char *outstr, int len)
/******************************************************************************/
struct session_item *DEFAULT_CC
session_get_bydata(char *name, int width, int height, int bpp, int type, char *client_ip)
session_get_bydata(const char *name, int width, int height, int bpp, int type,
const char *client_ip)
{
struct session_chain *tmp;
enum SESMAN_CFG_SESS_POLICY policy = g_cfg->sess.policy;
@ -1016,7 +1017,7 @@ session_get_bypid(int pid)
/******************************************************************************/
struct SCP_DISCONNECTED_SESSION *
session_get_byuser(char *user, int *cnt, unsigned char flags)
session_get_byuser(const char *user, int *cnt, unsigned char flags)
{
struct session_chain *tmp;
struct SCP_DISCONNECTED_SESSION *sess;

View File

@ -91,7 +91,8 @@ struct session_chain
*
*/
struct session_item* DEFAULT_CC
session_get_bydata(char* name, int width, int height, int bpp, int type, char *client_ip);
session_get_bydata(const char *name, int width, int height, int bpp, int type,
const char *client_ip);
#ifndef session_find_item
#define session_find_item(a, b, c, d, e, f) session_get_bydata(a, b, c, d, e, f);
#endif
@ -147,6 +148,6 @@ session_get_bypid(int pid);
*
*/
struct SCP_DISCONNECTED_SESSION*
session_get_byuser(char* user, int* cnt, unsigned char flags);
session_get_byuser(const char *user, int *cnt, unsigned char flags);
#endif

View File

@ -129,18 +129,18 @@ int main(int argc, char **argv)
sock = g_tcp_socket();
if (sock < 0)
{
LOG_DBG("Socket open error, g_tcp_socket() failed\n");
LOG_DBG("Socket open error, g_tcp_socket() failed");
return 1;
}
s = scp_session_create();
c = scp_connection_create(sock);
LOG_DBG("Connecting to %s:%s with user %s (%s)\n", serv, port, user, pass);
LOG_DBG("Connecting to %s:%s with user %s (%s)", serv, port, user, pass);
if (0 != g_tcp_connect(sock, serv, port))
{
LOG_DBG("g_tcp_connect() error\n");
LOG_DBG("g_tcp_connect() error");
return 1;
}
@ -153,7 +153,7 @@ int main(int argc, char **argv)
if (SCP_CLIENT_STATE_OK != e)
{
LOG_DBG("libscp error connecting: %s %d\n", s->errstr, (int)e);
LOG_DBG("libscp error connecting: %s %d", s->errstr, (int)e);
}
if (0 == g_strncmp(cmnd, "list", 5))

View File

@ -48,7 +48,7 @@ auth_account_disabled(struct spwd *stp);
/******************************************************************************/
/* returns boolean */
long DEFAULT_CC
auth_userpass(char *user, char *pass, int *errorcode)
auth_userpass(const char *user, const char *pass, int *errorcode)
{
const char *encr;
const char *epass;
@ -125,7 +125,7 @@ auth_set_env(long in_val)
/******************************************************************************/
int DEFAULT_CC
auth_check_pwd_chg(char *user)
auth_check_pwd_chg(const char *user)
{
struct passwd *spw;
struct spwd *stp;
@ -182,7 +182,7 @@ auth_check_pwd_chg(char *user)
}
int DEFAULT_CC
auth_change_pwd(char *user, char *newpwd)
auth_change_pwd(const char *user, const char *newpwd)
{
struct passwd *spw;
struct spwd *stp;

View File

@ -44,7 +44,7 @@ extern struct config_sesman* g_cfg; /* in sesman.c */
/******************************************************************************/
/* returns boolean */
long DEFAULT_CC
auth_userpass(char *user, char *pass, int *errorcode)
auth_userpass(const char *user, const char *pass, int *errorcode)
{
int ret = auth_userokay(user, NULL, "auth-xrdp", pass);
return ret;
@ -74,13 +74,13 @@ auth_set_env(long in_val)
/******************************************************************************/
int DEFAULT_CC
auth_check_pwd_chg(char* user)
auth_check_pwd_chg(const char *user)
{
return 0;
}
int DEFAULT_CC
auth_change_pwd(char* user, char* newpwd)
auth_change_pwd(const char *user, const char *newpwd)
{
return 0;
}

View File

@ -396,7 +396,7 @@ cleanup:
/******************************************************************************/
/* returns boolean */
int DEFAULT_CC
auth_userpass(char *user, char *pass, int *errorcode)
auth_userpass(const char *user, const char *pass, int *errorcode)
{
struct k_opts opts;
struct k5_data k5;

View File

@ -102,7 +102,7 @@ get_service_name(char *service_name)
Stores the detailed error code in the errorcode variable*/
long DEFAULT_CC
auth_userpass(char *user, char *pass, int *errorcode)
auth_userpass(const char *user, const char *pass, int *errorcode)
{
int error;
struct t_auth_info *auth_info;

View File

@ -34,7 +34,7 @@
/******************************************************************************/
/* returns boolean */
int DEFAULT_CC
auth_userpass(char *user, char *pass, int *errorcode)
auth_userpass(const char *user, const char *pass, int *errorcode)
{
pam_handle_t *pamh;
pam_userpass_t userpass;

View File

@ -48,13 +48,14 @@ grey=dedede
#red=ff0000
#green=00ff00
#background=626c72
#autorun=xrdp1
#hidelogwindow=yes
# when true, userid/password *must* be passed on cmd line
# require_credentials=yes
# set a default entry for autorun if the client send login and pass directly
# Section name to use for automatic login if the client sends username
# and password
autorun=xrdp1
bulk_compression=yes

View File

@ -471,7 +471,7 @@ xrdp_bitmap_load(struct xrdp_bitmap *self, const char *filename, int *palette)
/* read bmp header */
if (g_file_seek(fd, 14) < 0)
{
log_message(LOG_LEVEL_ERROR, "xrdp_bitmap_load: seek error in file %s\n",
log_message(LOG_LEVEL_ERROR, "xrdp_bitmap_load: seek error in file %s",
filename);
free_stream(s);
g_file_close(fd);
@ -505,7 +505,7 @@ xrdp_bitmap_load(struct xrdp_bitmap *self, const char *filename, int *palette)
{
if (g_file_seek(fd, 14 + header.size) < 0)
{
log_message(LOG_LEVEL_ERROR, "xrdp_bitmap_load: seek error in file %s\n",
log_message(LOG_LEVEL_ERROR, "xrdp_bitmap_load: seek error in file %s",
filename);
}
xrdp_bitmap_resize(self, header.image_width, header.image_height);
@ -562,7 +562,7 @@ xrdp_bitmap_load(struct xrdp_bitmap *self, const char *filename, int *palette)
/* read palette */
if (g_file_seek(fd, 14 + header.size) < 0)
{
log_message(LOG_LEVEL_ERROR, "xrdp_bitmap_load: seek error in file %s\n",
log_message(LOG_LEVEL_ERROR, "xrdp_bitmap_load: seek error in file %s",
filename);
}
init_stream(s, 8192);
@ -623,7 +623,7 @@ xrdp_bitmap_load(struct xrdp_bitmap *self, const char *filename, int *palette)
/* read palette */
if (g_file_seek(fd, 14 + header.size) < 0)
{
log_message(LOG_LEVEL_ERROR, "xrdp_bitmap_load: seek error in file %s\n",
log_message(LOG_LEVEL_ERROR, "xrdp_bitmap_load: seek error in file %s",
filename);
}
init_stream(s, 8192);