Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Psheng
xrdp
xrdp-avahi.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File xrdp-avahi.diff of Package xrdp
diff -uNr xrdp-0.9.20.orig/common/arch.h xrdp-0.9.20/common/arch.h --- xrdp-0.9.20.orig/common/arch.h 2023-06-24 02:54:59.271006258 +0800 +++ xrdp-0.9.20/common/arch.h 2023-06-24 03:05:20.445622482 +0800 @@ -21,27 +21,7 @@ #include <stdlib.h> -#if defined(HAVE_STDINT_H) #include <stdint.h> -#else -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -typedef signed int int32_t; -typedef unsigned int uint32_t; -#if defined(_WIN64) -typedef signed __int64 int64_t; -typedef unsigned __int64 uint64_t; -typedef signed __int64 intptr_t; -typedef unsigned __int64 uintptr_t; -#else -typedef signed long long int64_t; -typedef unsigned long long uint64_t; -typedef signed long intptr_t; -typedef unsigned long uintptr_t; -#endif -#endif typedef int bool_t; diff -uNr xrdp-0.9.20.orig/configure.ac xrdp-0.9.20/configure.ac --- xrdp-0.9.20.orig/configure.ac 2023-06-24 02:54:59.287006134 +0800 +++ xrdp-0.9.20/configure.ac 2023-06-24 02:57:18.881443290 +0800 @@ -9,6 +9,7 @@ AC_C_CONST AC_PROG_LIBTOOL +PKG_CHECK_MODULES(AVAHI, avahi-client >= 0.6.4) PKG_PROG_PKG_CONFIG if test "x$PKG_CONFIG" = "x"; then AC_MSG_ERROR([please install pkg-config]) diff -uNr xrdp-0.9.20.orig/xrdp/Makefile.am xrdp-0.9.20/xrdp/Makefile.am --- xrdp-0.9.20.orig/xrdp/Makefile.am 2023-06-24 02:54:59.271006258 +0800 +++ xrdp-0.9.20/xrdp/Makefile.am 2023-06-24 03:29:24.330763336 +0800 @@ -14,7 +14,8 @@ -I$(top_srcdir)/common \ -I$(top_srcdir)/sesman/libscp \ -I$(top_srcdir)/libxrdp \ - $(IMLIB2_CFLAGS) + $(IMLIB2_CFLAGS) \ + $(AVAHI_CFLAGS) XRDP_EXTRA_LIBS = @@ -44,6 +45,7 @@ lang.c \ xrdp.c \ xrdp.h \ + xrdp_avahi.c \ xrdp_bitmap.c \ xrdp_bitmap_load.c \ xrdp_bitmap_common.c \ @@ -65,8 +67,8 @@ $(top_builddir)/sesman/libscp/libscp.la \ $(top_builddir)/libxrdp/libxrdp.la \ $(IMLIB2_LIBS) \ - $(XRDP_EXTRA_LIBS) - + $(XRDP_EXTRA_LIBS) \ + $(AVAHI_LIBS) xrdpsysconfdir=$(sysconfdir)/xrdp if MACOS diff -uNr xrdp-0.9.20.orig/xrdp/xrdp_avahi.c xrdp-0.9.20/xrdp/xrdp_avahi.c --- xrdp-0.9.20.orig/xrdp/xrdp_avahi.c 1970-01-01 08:00:00.000000000 +0800 +++ xrdp-0.9.20/xrdp/xrdp_avahi.c 2023-06-24 04:05:47.897239902 +0800 @@ -0,0 +1,181 @@ +/* + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + xrdp: A Remote Desktop Protocol server. + Copyright (C) Novell, Inc. 2008 + + avahi integration + +*/ + +#if defined(HAVE_CONFIG_H) +#include <config_ac.h> +#endif +#include <stdio.h> +#include <unistd.h> + +#include <avahi-client/client.h> +#include <avahi-client/publish.h> +#include <avahi-common/thread-watch.h> + +#include <common/string_calls.h> +#include <xrdp.h> +#include "log.h" +static AvahiClient *client = NULL; +static AvahiThreadedPoll *threaded_poll = NULL; +static AvahiEntryGroup *avahi_group = NULL; + +static const char *_service_name = "RDP service on %s"; + +static void +avahi_client_callback (AvahiClient *c, + AvahiClientState state, + void *userdata) +{ + switch (state) { + case AVAHI_CLIENT_S_RUNNING: + avahi_group = avahi_entry_group_new (c, 0, 0); + if (avahi_group) + { + char hname[512]; + char name[576]; + char port[8]; + + if (gethostname (hname, sizeof (hname))) + break; + + sprintf (name, _service_name, hname); + + xrdp_avahi_get_port (port); + + avahi_entry_group_add_service (avahi_group, + AVAHI_IF_UNSPEC, + AVAHI_PROTO_UNSPEC, + 0, + name, + "_rdp._tcp", + 0, + 0, + atoi (port), + NULL); + + avahi_entry_group_commit (avahi_group); + } + break; + case AVAHI_CLIENT_FAILURE: + case AVAHI_CLIENT_S_COLLISION: + case AVAHI_CLIENT_CONNECTING: + break; + case AVAHI_CLIENT_S_REGISTERING: + if (avahi_group) + avahi_entry_group_reset (avahi_group); + default: + break; + } +} + +int +xrdp_avahi_init (void) +{ + if (!(threaded_poll = avahi_threaded_poll_new ())) + return 1; + + if (!(client = avahi_client_new (avahi_threaded_poll_get (threaded_poll), + 0, + avahi_client_callback, + NULL, + NULL))) + return 1; + + if (avahi_threaded_poll_start (threaded_poll) < 0) + return 1; + + return 0; +} + +void +xrdp_avahi_fini (void) +{ + avahi_threaded_poll_stop (threaded_poll); + if (avahi_group) + avahi_entry_group_free (avahi_group); + avahi_client_free (client); + avahi_threaded_poll_free (threaded_poll); +} + +void +xrdp_avahi_get_port(char *port) +{ + const int port_bytes = 8; + int fd; + char cfg_file[256]; + + /* default to port 3389 */ + g_strncpy(port, "3389", port_bytes - 1); + + /* see if port or address is in xrdp.ini file */ + g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH); + fd = g_file_open(cfg_file); + + if (fd != -1) + { + struct list *names; + struct list *values; + + names = list_create(); + names->auto_free = 1; + values = list_create(); + values->auto_free = 1; + + if (file_read_section(fd, "globals", names, values) == 0) + { + int index; + char *val; + + for (index = 0; index < names->count; index++) + { + val = (char *)list_get_item(names, index); + + if (val != 0) + { + if (g_strcasecmp(val, "port") == 0) + { + val = (char *)list_get_item(values, index); + if (val[0] == '/') + { + g_strncpy(port, val, port_bytes - 1); + } + else + { + int error; + + error = g_atoi(val); + if ((error > 0) && (error < 65000)) + { + g_strncpy(port, val, port_bytes - 1); + } + } + } + } + } + } + + list_delete(names); + list_delete(values); + } + + if (fd != -1) + g_file_close(fd); +} diff -uNr xrdp-0.9.20.orig/xrdp/xrdp.h xrdp-0.9.20/xrdp/xrdp.h --- xrdp-0.9.20.orig/xrdp/xrdp.h 2023-06-24 02:54:59.271006258 +0800 +++ xrdp-0.9.20/xrdp/xrdp.h 2023-06-24 03:01:39.216522431 +0800 @@ -571,3 +571,10 @@ int server_session_info(struct xrdp_mod *mod, const char *data, int data_bytes); +/* xrdp_avahi.c */ +int +xrdp_avahi_init(void); +void +xrdp_avahi_fini(void); +void +xrdp_avahi_get_port(char *port);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor