int DEFAULT_CC access_login_mng_allowed(char* user) { int gid; int ok; if ((0 == g_strncmp(user, "root", 5)) && (0 == g_cfg->sec.allow_root)) { log_message(LOG_LEVEL_WARNING, "[MNG] ROOT login attempted, but root login is disabled"); return 0; } if (0 == g_cfg->sec.ts_admins_enable) { LOG_DBG("[MNG] Terminal Server Admin group is disabled," "allowing authentication",1); return 1; } if (0 != g_getuser_info(user, &gid, 0, 0, 0, 0)) { log_message(LOG_LEVEL_ERROR, "[MNG] Cannot read user info! - login denied"); return 0; } if (g_cfg->sec.ts_admins == gid) { LOG_DBG("[MNG] ts_users is user's primary group"); return 1; } if (0 != g_check_user_in_group(user, g_cfg->sec.ts_admins, &ok)) { log_message(LOG_LEVEL_ERROR, "[MNG] Cannot read group info! - login denied"); return 0; } if (ok) { return 1; } log_message(LOG_LEVEL_INFO, "[MNG] login denied for user %s", user); return 0; }
int main(int argc, char** argv, char** environ) { int fuse_group = 0; int ok = 0; char* home_dir = g_getenv("HOME"); l_config = g_malloc(sizeof(struct log_config), 1); if (argc != 2) { g_printf("Usage : vchannel_rdpdr USERNAME\n"); return 1; } if (disk_init() != LOG_STARTUP_OK) { g_printf("vchannel_rdpdr[main]: Enable to init log system\n"); g_free(l_config); return 1; } if ( g_getuser_info(argv[1], 0, 0, 0, 0, 0) == 1) { log_message(l_config, LOG_LEVEL_WARNING, "vchannel_rdpdr[main]: " "The username '%s' did not exist\n", argv[1]); } g_strncpy(username, argv[1], sizeof(username)); g_getgroup_info("fuse", &fuse_group); if (g_check_user_in_group(username, fuse_group, &ok) == 1) { log_message(l_config, LOG_LEVEL_WARNING, "vchannel_rdpdr[main]: " "Error while testing if user %s is member of fuse group", username); return 1; } if (ok == 0) { log_message(l_config, LOG_LEVEL_WARNING, "vchannel_rdpdr[main]: " "User %s is not allow to use fuse", username); return 1; } if (vchannel_init() == ERROR) { g_printf("vchannel_rdpdr[main]: Enable to init channel system\n"); g_free(l_config); return 1; } log_message(l_config, LOG_LEVEL_DEBUG, "vchannel_rdpdr[main]: " "Open channel to rdpdr main apps"); if (rdpfs_open() == 1) { log_message(l_config, LOG_LEVEL_ERROR, "vchannel_rdpdr[main]: " "Unable to open a connection to RDP filesystem"); } // share_desktop_purge(); share_bookmark_purge(); share_symlink_purge(); g_sprintf(mount_point, "%s/%s", home_dir, RDPDRIVE_NAME); log_message(l_config, LOG_LEVEL_DEBUG, "vchannel_rdpdr[main]: " "Rdpdrive is located on %s", mount_point); if (fuse_run() == 1) { log_message(l_config, LOG_LEVEL_DEBUG, "vchannel_rdpdr[main]: " "Fail to start fuse"); } g_free(l_config); }