Hi,

On 10/20/2014 02:19 PM, Laércio de Sousa wrote:
> It will allow extending functions like Xlib's XOpenDislay() or XCB's 
> xcb_connect()
> to allow passing an explicit authorization file path (they already allow 
> passing
> an explicit display number). This can be useful in exceptional cases where
> XAUTHORITY environment variable is not set at the time a X11 client is 
> launched.
> Currently, a X11 client that needs to connect to a display with a given
> authorization file needs to set XAUTHORITY itself (if not yet set) before 
> connecting.
> 
> Signed-off-by: Laércio de Sousa <laercioso...@sme-mogidascruzes.sp.gov.br>

Code looks good to me and is:

Acked-by: Hans de Goede <hdego...@redhat.com>

I think this should get a second look by someone more familiar with the Xau code
though, so I'll leave merging this up to someone else.

Regards,

Hans

> ---
>  AuGetAddr.c                          | 38 ++++++++++++++++++++++++++++--
>  AuGetBest.c                          | 36 +++++++++++++++++++++++++++--
>  include/X11/Xauth.h                  | 45 
> ++++++++++++++++++++++++++++++++++++
>  man/Xau.man                          | 20 ++++++++++++++--
>  man/XauGetAuthByAddrWithFile.man     |  1 +
>  man/XauGetBestAuthByAddrWithFile.man |  1 +
>  6 files changed, 135 insertions(+), 6 deletions(-)
>  create mode 100644 man/XauGetAuthByAddrWithFile.man
>  create mode 100644 man/XauGetBestAuthByAddrWithFile.man
> 
> diff --git a/AuGetAddr.c b/AuGetAddr.c
> index 6f5fe16..3aeffa4 100644
> --- a/AuGetAddr.c
> +++ b/AuGetAddr.c
> @@ -33,7 +33,8 @@ in this Software without prior written authorization from 
> The Open Group.
>  #define binaryEqual(a, b, len) (memcmp(a, b, len) == 0)
>  
>  Xauth *
> -XauGetAuthByAddr (
> +XauGetAuthByAddrWithFile (
> +_Xconst char*        auth_file,
>  #if NeedWidePrototypes
>  unsigned int family,
>  unsigned int address_length,
> @@ -59,7 +60,7 @@ _Xconst char*       name)
>      char    *auth_name;
>      Xauth   *entry;
>  
> -    auth_name = XauFileName ();
> +    auth_name = auth_file ? auth_file : XauFileName ();
>      if (!auth_name)
>       return NULL;
>      if (access (auth_name, R_OK) != 0)               /* checks REAL id */
> @@ -100,3 +101,36 @@ _Xconst char*    name)
>      (void) fclose (auth_file);
>      return entry;
>  }
> +
> +Xauth *
> +XauGetAuthByAddr (
> +#if NeedWidePrototypes
> +unsigned int family,
> +unsigned int address_length,
> +#else
> +unsigned short       family,
> +unsigned short       address_length,
> +#endif
> +_Xconst char*        address,
> +#if NeedWidePrototypes
> +unsigned int number_length,
> +#else
> +unsigned short       number_length,
> +#endif
> +_Xconst char*        number,
> +#if NeedWidePrototypes
> +unsigned int name_length,
> +#else
> +unsigned short       name_length,
> +#endif
> +_Xconst char*        name)
> +{
> +    XauGetAuthByAddrWithFile (NULL,
> +                              family,
> +                              address_length,
> +                              address,
> +                              number_length,
> +                              number,
> +                              name_length,
> +                              name);
> +}
> diff --git a/AuGetBest.c b/AuGetBest.c
> index 5556559..73ee907 100644
> --- a/AuGetBest.c
> +++ b/AuGetBest.c
> @@ -41,7 +41,8 @@ in this Software without prior written authorization from 
> The Open Group.
>  #define binaryEqual(a, b, len) (memcmp(a, b, len) == 0)
>  
>  Xauth *
> -XauGetBestAuthByAddr (
> +XauGetBestAuthByAddrWithFile (
> +    _Xconst char*    auth_file,
>  #if NeedWidePrototypes
>      unsigned int     family,
>      unsigned int     address_length,
> @@ -71,7 +72,7 @@ XauGetBestAuthByAddr (
>      unsigned short   fully_qual_address_length;
>  #endif
>  
> -    auth_name = XauFileName ();
> +    auth_name = auth_file ? auth_file : XauFileName ();
>      if (!auth_name)
>       return NULL;
>      if (access (auth_name, R_OK) != 0)               /* checks REAL id */
> @@ -161,3 +162,34 @@ XauGetBestAuthByAddr (
>      (void) fclose (auth_file);
>      return best;
>  }
> +
> +Xauth *
> +XauGetBestAuthByAddr (
> +#if NeedWidePrototypes
> +    unsigned int     family,
> +    unsigned int     address_length,
> +#else
> +    unsigned short   family,
> +    unsigned short   address_length,
> +#endif
> +    _Xconst char*    address,
> +#if NeedWidePrototypes
> +    unsigned int     number_length,
> +#else
> +    unsigned short   number_length,
> +#endif
> +    _Xconst char*    number,
> +    int                      types_length,
> +    char**           types,
> +    _Xconst int*     type_lengths)
> +{
> +    XauGetBestAuthByAddrWithFile (NULL,
> +                                  family,
> +                                  address_length,
> +                                  address,
> +                                  number_length,
> +                                  number,
> +                                  types_length,
> +                                  types,
> +                                  type_lengths);
> +}
> diff --git a/include/X11/Xauth.h b/include/X11/Xauth.h
> index a707bed..c5765ff 100644
> --- a/include/X11/Xauth.h
> +++ b/include/X11/Xauth.h
> @@ -112,6 +112,30 @@ unsigned short   /* name_length */,
>  _Xconst char*        /* name */
>  );
>  
> +Xauth *XauGetAuthByAddrWithFile(
> +_Xconst char*        /* auth_file */,
> +#if NeedWidePrototypes
> +unsigned int /* family */,
> +unsigned int /* address_length */,
> +#else
> +unsigned short       /* family */,
> +unsigned short       /* address_length */,
> +#endif
> +_Xconst char*        /* address */,
> +#if NeedWidePrototypes
> +unsigned int /* number_length */,
> +#else
> +unsigned short       /* number_length */,
> +#endif
> +_Xconst char*        /* number */,
> +#if NeedWidePrototypes
> +unsigned int /* name_length */,
> +#else
> +unsigned short       /* name_length */,
> +#endif
> +_Xconst char*        /* name */
> +);
> +
>  Xauth *XauGetBestAuthByAddr(
>  #if NeedWidePrototypes
>  unsigned int /* family */,
> @@ -132,6 +156,27 @@ char**           /* type_names */,
>  _Xconst int* /* type_lengths */
>  );
>  
> +Xauth *XauGetBestAuthByAddrWithFile(
> +_Xconst char*        /* auth_file */,
> +#if NeedWidePrototypes
> +unsigned int /* family */,
> +unsigned int /* address_length */,
> +#else
> +unsigned short       /* family */,
> +unsigned short       /* address_length */,
> +#endif
> +_Xconst char*        /* address */,
> +#if NeedWidePrototypes
> +unsigned int /* number_length */,
> +#else
> +unsigned short       /* number_length */,
> +#endif
> +_Xconst char*        /* number */,
> +int          /* types_length */,
> +char**               /* type_names */,
> +_Xconst int* /* type_lengths */
> +);
> +
>  void XauDisposeAuth(
>  Xauth*               /* auth */
>  );
> diff --git a/man/Xau.man b/man/Xau.man
> index d1b6603..e7060c7 100644
> --- a/man/Xau.man
> +++ b/man/Xau.man
> @@ -56,11 +56,23 @@ Xauth *XauGetAuthByAddr (unsigned short \fIfamily\fP\^, 
> unsigned short
>  \fInumber_length\fP\^, const char *\fInumber\fP\^, unsigned short
>  \fIname_length\fP\^, const char *\fIname\fP\^);
>  .HP
> +Xauth *XauGetAuthByAddrWithFile (const char* \fIauth_file\fP\^,
> +unsigned short \fIfamily\fP\^, unsigned short \fIaddress_length\fP\^,
> +const char *\fIaddress\fP\^, unsigned short \fInumber_length\fP\^,
> +const char *\fInumber\fP\^, unsigned short \fIname_length\fP\^,
> +const char *\fIname\fP\^);
> +.HP
>  Xauth *XauGetBestAuthByAddr (unsigned short \fIfamily\fP\^, unsigned short
>  \fIaddress_length\fP\^, const char *\fIaddress\fP\^, unsigned short
>  \fInumber_length\fP\^, const char *\fInumber\fP\^, int \fItypes_length\fP\^,
>  char **\fItypes\fR\^, const int *\fItype_lengths\fR\^);
>  .HP
> +Xauth *XauGetBestAuthByAddrWithFile (const char* \fIauth_file\fP\^,
> +unsigned short \fIfamily\fP\^, unsigned short \fIaddress_length\fP\^,
> +const char *\fIaddress\fP\^, unsigned short \fInumber_length\fP\^,
> +const char *\fInumber\fP\^, int \fItypes_length\fP\^, char **\fItypes\fR\^,
> +const int *\fItype_lengths\fR\^);
> +.HP
>  int XauLockAuth (const char *\fIfile_name\fP\^, int \fIretries\fP\^, int
>  \fItimeout\fP\^, long \fIdead\fP\^);
>  .HP
> @@ -85,7 +97,9 @@ returns 1 on success, 0 on failure.
>  .PP
>  \fBXauGetAuthByAddr\fP searches for an entry which matches the given network
>  address/display number pair.  The entry is \fBnot\fP statically allocated
> -and should be freed by calling \fIXauDisposeAuth\fP.
> +and should be freed by calling \fIXauDisposeAuth\fP. It gets authorization
> +file path by calling \fIXauFileName\fP, but its corresponding function
> +\fBXauGetAuthByAddrWithFile\fP allows passing an explicit one.
>  .PP
>  \fBXauGetBestAuthByAddr\fP is similar to \fBXauGetAuthByAddr\fP, except
>  that a list of acceptable authentication methods is specified.  Xau will
> @@ -94,7 +108,9 @@ most secure authentication method).  The \fItypes\fP 
> argument is an array of
>  strings, one string for each authentication method.  \fItypes_length\fP
>  specifies how many elements are in the \fItypes\fP array.
>  \fItypes_lengths\fP is an array of integers representing the length
> -of each string.
> +of each string. It gets authorization file path by calling \fIXauFileName\fP,
> +but its corresponding function \fBXauGetBestAuthByAddrWithFile\fP allows
> +passing an explicit one.
>  .PP
>  \fBXauLockAuth\fP does the work necessary to synchronously update an
>  authorization file.  First it makes two file names, one with ``-c'' appended
> diff --git a/man/XauGetAuthByAddrWithFile.man 
> b/man/XauGetAuthByAddrWithFile.man
> new file mode 100644
> index 0000000..df111d6
> --- /dev/null
> +++ b/man/XauGetAuthByAddrWithFile.man
> @@ -0,0 +1 @@
> +.so man__libmansuffix__/Xau.__libmansuffix__
> diff --git a/man/XauGetBestAuthByAddrWithFile.man 
> b/man/XauGetBestAuthByAddrWithFile.man
> new file mode 100644
> index 0000000..df111d6
> --- /dev/null
> +++ b/man/XauGetBestAuthByAddrWithFile.man
> @@ -0,0 +1 @@
> +.so man__libmansuffix__/Xau.__libmansuffix__
> 
_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to