summaryrefslogtreecommitdiffstats
path: root/kinit/lnusertemp.c
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-02 21:21:15 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-02 21:21:15 +0000
commit96900dbce3aaa1fcac74a07a71482c5c6fcd3cab (patch)
treebf3fc68d0dcc660fce0e21171373a2d4e2395707 /kinit/lnusertemp.c
parent5f99bff82d3413803bcc652999f4f631058179d6 (diff)
downloadtdelibs-96900dbce3aaa1fcac74a07a71482c5c6fcd3cab.tar.gz
tdelibs-96900dbce3aaa1fcac74a07a71482c5c6fcd3cab.zip
* 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
Diffstat (limited to 'kinit/lnusertemp.c')
-rw-r--r--kinit/lnusertemp.c25
1 files changed, 19 insertions, 6 deletions
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);