| | @@ -680,11 +680,11 @@ |
| 680 | 680 | if( fossil_strcmp(g.zLogin,"nobody")==0 ){ |
| 681 | 681 | g.zLogin = 0; |
| 682 | 682 | } |
| 683 | 683 | |
| 684 | 684 | /* Set the capabilities */ |
| 685 | | - login_set_capabilities(zCap); |
| 685 | + login_set_capabilities(zCap, 0); |
| 686 | 686 | login_set_anon_nobody_capabilities(); |
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | /* |
| 690 | 690 | ** Memory of settings |
| | @@ -698,26 +698,32 @@ |
| 698 | 698 | void login_set_anon_nobody_capabilities(void){ |
| 699 | 699 | if( g.zLogin && login_anon_once ){ |
| 700 | 700 | const char *zCap; |
| 701 | 701 | /* All logged-in users inherit privileges from "nobody" */ |
| 702 | 702 | zCap = db_text("", "SELECT cap FROM user WHERE login = 'nobody'"); |
| 703 | | - login_set_capabilities(zCap); |
| 703 | + login_set_capabilities(zCap, 0); |
| 704 | 704 | if( fossil_strcmp(g.zLogin, "nobody")!=0 ){ |
| 705 | 705 | /* All logged-in users inherit privileges from "anonymous" */ |
| 706 | 706 | zCap = db_text("", "SELECT cap FROM user WHERE login = 'anonymous'"); |
| 707 | | - login_set_capabilities(zCap); |
| 707 | + login_set_capabilities(zCap, 0); |
| 708 | 708 | } |
| 709 | 709 | login_anon_once = 0; |
| 710 | 710 | } |
| 711 | 711 | } |
| 712 | 712 | |
| 713 | +/* |
| 714 | +** Flags passed into the 2nd argument of login_set_capabilities(). |
| 715 | +*/ |
| 716 | +#if INTERFACE |
| 717 | +#define LOGIN_IGNORE_U 0x01 /* Ignore "u" */ |
| 718 | +#define LOGIN_IGNORE_V 0x01 /* Ignore "v" */ |
| 719 | +#endif |
| 720 | + |
| 713 | 721 | /* |
| 714 | 722 | ** Set the global capability flags based on a capability string. |
| 715 | 723 | */ |
| 716 | | -void login_set_capabilities(const char *zCap){ |
| 717 | | - static char *zDev = 0; |
| 718 | | - static char *zUser = 0; |
| 724 | +void login_set_capabilities(const char *zCap, unsigned flags){ |
| 719 | 725 | int i; |
| 720 | 726 | for(i=0; zCap[i]; i++){ |
| 721 | 727 | switch( zCap[i] ){ |
| 722 | 728 | case 's': g.okSetup = 1; /* Fall thru into Admin */ |
| 723 | 729 | case 'a': g.okAdmin = g.okRdTkt = g.okWrTkt = g.okZip = |
| | @@ -751,23 +757,25 @@ |
| 751 | 757 | case 'x': g.okPrivate = 1; break; |
| 752 | 758 | |
| 753 | 759 | /* The "u" privileges is a little different. It recursively |
| 754 | 760 | ** inherits all privileges of the user named "reader" */ |
| 755 | 761 | case 'u': { |
| 756 | | - if( zUser==0 ){ |
| 762 | + if( (flags & LOGIN_IGNORE_U)==0 ){ |
| 763 | + const char *zUser; |
| 757 | 764 | zUser = db_text("", "SELECT cap FROM user WHERE login='reader'"); |
| 758 | | - login_set_capabilities(zUser); |
| 765 | + login_set_capabilities(zUser, flags | LOGIN_IGNORE_U); |
| 759 | 766 | } |
| 760 | 767 | break; |
| 761 | 768 | } |
| 762 | 769 | |
| 763 | 770 | /* The "v" privileges is a little different. It recursively |
| 764 | 771 | ** inherits all privileges of the user named "developer" */ |
| 765 | 772 | case 'v': { |
| 766 | | - if( zDev==0 ){ |
| 773 | + if( (flags & LOGIN_IGNORE_V)==0 ){ |
| 774 | + const char *zDev; |
| 767 | 775 | zDev = db_text("", "SELECT cap FROM user WHERE login='developer'"); |
| 768 | | - login_set_capabilities(zDev); |
| 776 | + login_set_capabilities(zDev, flags | LOGIN_IGNORE_V); |
| 769 | 777 | } |
| 770 | 778 | break; |
| 771 | 779 | } |
| 772 | 780 | } |
| 773 | 781 | } |
| | @@ -859,11 +867,11 @@ |
| 859 | 867 | } |
| 860 | 868 | if( fossil_strcmp(zUser,"nobody")==0 ) zUser = 0; |
| 861 | 869 | g.zLogin = fossil_strdup(zUser); |
| 862 | 870 | |
| 863 | 871 | /* Set the capabilities */ |
| 864 | | - login_set_capabilities(zCap); |
| 872 | + login_set_capabilities(zCap, 0); |
| 865 | 873 | login_anon_once = 1; |
| 866 | 874 | login_set_anon_nobody_capabilities(); |
| 867 | 875 | } |
| 868 | 876 | |
| 869 | 877 | /* |
| 870 | 878 | |