From 96900dbce3aaa1fcac74a07a71482c5c6fcd3cab Mon Sep 17 00:00:00 2001 From: tpearson Date: Thu, 2 Sep 2010 21:21:15 +0000 Subject: * Large set of SuSE patches to fix bugs and add functionality * kdemm is included but not used by knotify as it does not work out of the box git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1171141 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kinit/lnusertemp.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'kinit/lnusertemp.c') diff --git a/kinit/lnusertemp.c b/kinit/lnusertemp.c index 867f1fb95..fdbf8ae0b 100644 --- a/kinit/lnusertemp.c +++ b/kinit/lnusertemp.c @@ -39,7 +39,7 @@ int check_tmp_dir(const char *tmp_dir); int create_link(const char *file, const char *tmp_dir); -int build_link(const char *tmp_prefix, const char *kde_prefix); +int build_link(const char *tmp_prefix, const char *kde_prefix, int kdehostname); int check_tmp_dir(const char *tmp_dir) { @@ -92,7 +92,7 @@ int create_link(const char *file, const char *tmp_dir) #ifndef PATH_MAX #define PATH_MAX 4096 #endif -int build_link(const char *tmp_prefix, const char *kde_prefix) +int build_link(const char *tmp_prefix, const char *kde_prefix, int kdehostname) { struct passwd *pw_ent; char kde_tmp_dir[PATH_MAX+1]; @@ -160,10 +160,21 @@ int build_link(const char *tmp_prefix, const char *kde_prefix) } strncat(kde_tmp_dir, kde_prefix, PATH_MAX - strlen(kde_tmp_dir)); - if (gethostname(kde_tmp_dir+strlen(kde_tmp_dir), PATH_MAX - strlen(kde_tmp_dir) - 1) != 0) + + if( kdehostname ) + { + if( getenv("XAUTHLOCALHOSTNAME")) + strncat(kde_tmp_dir+strlen(kde_tmp_dir), getenv("XAUTHLOCALHOSTNAME"), PATH_MAX - strlen(kde_tmp_dir) - 1); + else + return 0; + } + else { - perror("Aborting. Could not determine hostname: "); - exit(255); + if (gethostname(kde_tmp_dir+strlen(kde_tmp_dir), PATH_MAX - strlen(kde_tmp_dir) - 1) != 0) + { + perror("Could not determine hostname: "); + return 1; + } } kde_tmp_dir[sizeof(kde_tmp_dir)-1] = '\0'; @@ -269,7 +280,9 @@ int main(int argc, char **argv) kde_prefix = "/cache-"; } - res = build_link(tmp_prefix, kde_prefix); + res = build_link(tmp_prefix, kde_prefix, 1); + if( build_link(tmp_prefix, kde_prefix, 0)) + res = 1; free(tmp_prefix); -- cgit v1.2.1