src/protocols/zephyr/ZGetSender.c

Mon, 25 Apr 2005 01:53:01 +0000

author
Arun Tharuvai <aatharuv@mit.edu>
date
Mon, 25 Apr 2005 01:53:01 +0000
changeset 10867
b39f9b646d6c
parent 10038
3589c2eed81c
child 11105
842fa517e08c
permissions
-rw-r--r--

[gaim-migrate @ 12553]
sf patch #991208, from Arun A Tharuvai
"Here's a patch, against current CVS, to build and
compile zephyr on Windows, with, or without Kerberos 4
Authentication.

In order to be built (and run) with Kerberos 4
authentication, the Kerberos for Windows SDK (version
2.6.3 is the current version) (licensed under the MIT
license) and runtimes, both available from

http://web.mit.edu/kerberos/www/dist/index.html#KFW2.6.3

Also, USE_KRB4 should be set to true in the attached
Makefile.mingw

As on the UNIX side, an external 'zhm' binary needs to run
for zephyr to work. Source and a win32 executable
(using code from gaim's libzephyr, and also MIT's
zephyr distribution), can be found at
http://web.mit.edu/aatharuv/www/zhm-windows.html"

I decided not to make zephyr compiled by default in Windows.
If you want to compile it, I think you you can modify the root
Makefile.mingw or cd to the src/protocols/zephyr/ directory
and run "make -f Makefile.mingw" using make from mingw

committer: Mark Doliner <markdoliner@pidgin.im>

/* This file is part of the Project Athena Zephyr Notification System.
 * It contains source for the ZGetSender.c function.
 *
 *	Created by:	Robert French
 *
 *	$Source$
 *	$Author: thekingant $
 *
 *	Copyright (c) 1987, 1991 by the Massachusetts Institute of Technology.
 *	For copying and distribution information, see the file
 *	"mit-copyright.h". 
 */
/* $Header$ */

#include "internal.h"

#ifndef lint
static const char rcsid_ZGetSender_c[] =
    "$Id: ZGetSender.c 12553 2005-04-25 01:53:01Z thekingant $";
#endif

#ifndef WIN32
#include <pwd.h>
#endif

char *ZGetSender()
{
    struct passwd *pw;
#ifdef ZEPHYR_USES_KERBEROS
    char pname[ANAME_SZ], pinst[INST_SZ], prealm[REALM_SZ];
    static char sender[ANAME_SZ+INST_SZ+REALM_SZ+3] = "";
	long int kerror;
#else
    static char sender[128] = "";
#endif

#ifdef WIN32
	unsigned long sender_size = 127;
#endif

    /* Return it if already cached */

    /*    if (*sender)
	return (sender);
    */

#ifdef ZEPHYR_USES_KERBEROS
	if ((kerror = krb_get_tf_fullname((char *)TKT_FILE, pname, pinst, prealm)) == KSUCCESS)
    {
	(void) sprintf(sender, "%s%s%s@%s", pname, (pinst[0]?".":""),
		       pinst, prealm);
	return (sender);
    } else {
	sprintf(sender,"%s@%s",(username?username:"unknown"),__Zephyr_realm);
	return (sender);
    }
#endif

    /* XXX a uid_t is a u_short (now),  but getpwuid
     * wants an int. AARGH! */
#ifdef WIN32
    GetUserName(sender, &sender_size);
#else
    pw = getpwuid((int) getuid());
    if (!pw)
	return ("unknown");
    (void) sprintf(sender, "%s@%s", pw->pw_name, __Zephyr_realm);
#endif
    return (sender);
}

mercurial