|
9 | 9 | *
|
10 | 10 | *
|
11 | 11 | * IDENTIFICATION
|
12 |
| - * $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.78 2003/06/06 16:25:35 tgl Exp $ |
| 12 | + * $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.79 2003/06/27 19:08:37 tgl Exp $ |
13 | 13 | *
|
14 | 14 | *-------------------------------------------------------------------------
|
15 | 15 | */
|
@@ -721,25 +721,29 @@ assign_client_encoding(const char *value, bool doit, bool interactive)
|
721 | 721 | * When resetting session auth after an error, we can't expect to do catalog
|
722 | 722 | * lookups. Hence, the stored form of the value must provide a numeric userid
|
723 | 723 | * that can be re-used directly. We store the string in the form of
|
724 |
| - * NAMEDATALEN 'x's followed by the numeric userid --- this cannot conflict |
725 |
| - * with any valid user name, because of the NAMEDATALEN limit on names. |
| 724 | + * NAMEDATALEN 'x's, followed by T or F to indicate superuserness, followed |
| 725 | + * by the numeric userid --- this cannot conflict with any valid user name, |
| 726 | + * because of the NAMEDATALEN limit on names. |
726 | 727 | */
|
727 | 728 | const char *
|
728 | 729 | assign_session_authorization(const char *value, bool doit, bool interactive)
|
729 | 730 | {
|
730 | 731 | AclId usesysid = 0;
|
| 732 | + bool is_superuser = false; |
731 | 733 | char *result;
|
732 | 734 |
|
733 |
| - if (strspn(value, "x") == NAMEDATALEN) |
| 735 | + if (strspn(value, "x") == NAMEDATALEN && |
| 736 | + (value[NAMEDATALEN] == 'T' || value[NAMEDATALEN] == 'F')) |
734 | 737 | {
|
735 | 738 | /* might be a saved numeric userid */
|
736 | 739 | char *endptr;
|
737 | 740 |
|
738 |
| - usesysid = (AclId) strtoul(value + NAMEDATALEN, &endptr, 10); |
| 741 | + usesysid = (AclId) strtoul(value + NAMEDATALEN + 1, &endptr, 10); |
739 | 742 |
|
740 |
| - if (endptr != value + NAMEDATALEN && *endptr == '\0') |
| 743 | + if (endptr != value + NAMEDATALEN + 1 && *endptr == '\0') |
741 | 744 | {
|
742 |
| - /* syntactically valid, so use the numeric user ID */ |
| 745 | + /* syntactically valid, so use the numeric user ID and flag */ |
| 746 | + is_superuser = (value[NAMEDATALEN] == 'T'); |
743 | 747 | }
|
744 | 748 | else
|
745 | 749 | usesysid = 0;
|
@@ -771,20 +775,23 @@ assign_session_authorization(const char *value, bool doit, bool interactive)
|
771 | 775 | }
|
772 | 776 |
|
773 | 777 | usesysid = ((Form_pg_shadow) GETSTRUCT(userTup))->usesysid;
|
774 |
| - |
| 778 | + is_superuser = ((Form_pg_shadow) GETSTRUCT(userTup))->usesuper; |
| 779 | + |
775 | 780 | ReleaseSysCache(userTup);
|
776 | 781 | }
|
777 | 782 |
|
778 | 783 | if (doit)
|
779 |
| - SetSessionAuthorization(usesysid); |
| 784 | + SetSessionAuthorization(usesysid, is_superuser); |
780 | 785 |
|
781 | 786 | result = (char *) malloc(NAMEDATALEN + 32);
|
782 | 787 | if (!result)
|
783 | 788 | return NULL;
|
784 | 789 |
|
785 | 790 | memset(result, 'x', NAMEDATALEN);
|
786 | 791 |
|
787 |
| - snprintf(result + NAMEDATALEN, 32, "%lu", (unsigned long) usesysid); |
| 792 | + snprintf(result + NAMEDATALEN, 32, "%c%lu", |
| 793 | + is_superuser ? 'T' : 'F', |
| 794 | + (unsigned long) usesysid); |
788 | 795 |
|
789 | 796 | return result;
|
790 | 797 | }
|
|
0 commit comments