summaryrefslogtreecommitdiff
path: root/lib/ZLocations.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ZLocations.c')
-rw-r--r--lib/ZLocations.c39
1 files changed, 33 insertions, 6 deletions
diff --git a/lib/ZLocations.c b/lib/ZLocations.c
index 670a61c..e9cc83c 100644
--- a/lib/ZLocations.c
+++ b/lib/ZLocations.c
@@ -16,18 +16,45 @@
#include <zephyr/zephyr_internal.h>
+#include <pwd.h>
+#include <sys/file.h>
+
Code_t ZSetLocation()
{
- ZNotice_t notice;
-
- notice.z_kind = UNACKED;
+ int retval,quiet;
+ ZNotice_t notice,retnotice;
+ ZPacket_t buffer;
+ char bfr[BUFSIZ];
+ struct passwd *pw;
+
+ quiet = 0;
+ if (pw = getpwuid(getuid())) {
+ sprintf(bfr,"%s/.hideme",pw->pw_dir);
+ quiet = !access(bfr,F_OK);
+ }
+
+ notice.z_kind = ACKED;
notice.z_port = 0;
notice.z_class = LOGIN_CLASS;
- notice.z_class_inst = (char *)Z_GetSender();
- notice.z_opcode = LOGIN_USER_LOGIN;
+ notice.z_class_inst = ZGetSender();
+ notice.z_opcode = quiet?LOGIN_QUIET_LOGIN:LOGIN_USER_LOGIN;
notice.z_sender = 0;
notice.z_recipient = "";
notice.z_message_len = 0;
- return (ZSendNotice(&notice,1));
+ if ((retval = ZSendNotice(&notice,1)) != ZERR_NONE)
+ return (retval);
+
+ if ((retval = ZIfNotice(buffer,sizeof buffer,&retnotice,0,
+ Z_UIDpred,(char *)&notice.z_uid)) !=
+ ZERR_NONE)
+ return (retval);
+
+ if (retnotice.z_kind == SERVNAK)
+ return (ZERR_SERVNAK);
+
+ if (retnotice.z_kind != SERVACK)
+ return (ZERR_INTERNAL);
+
+ return (ZERR_NONE);
}