fedora-krb 0.1.0 → 0.1.1
raw patch · 4 files changed
+46/−26 lines, 4 filesdep +extradep +simple-promptdep +unix
Dependencies added: extra, simple-prompt, unix
Files
- ChangeLog.md +6/−1
- LICENSE +11/−12
- fedora-krb.cabal +7/−4
- src/Fedora/Krb.hs +22/−9
ChangeLog.md view
@@ -1,4 +1,9 @@-# Revision history for krb+# Release history for krb++## 0.1.1 (2026-11-23, @juhp)+- prompt for FAS user if no existing krb principal+- add haddock docs+- update GPLv2 text (@bkmgit) ## 0.1.0 (2025-03-05) - initial release: provides krbTicket, maybeFasIdFromKrb, fasIdFromKrb
LICENSE view
@@ -1,12 +1,12 @@- GNU GENERAL PUBLIC LICENSE- Version 2, June 1991+ GNU GENERAL PUBLIC LICENSE+ Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc.,- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA+ <https://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - Preamble+ Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public@@ -56,7 +56,7 @@ The precise terms and conditions for copying, distribution and modification follow. - GNU GENERAL PUBLIC LICENSE+ GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains@@ -255,7 +255,7 @@ of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - NO WARRANTY+ NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN@@ -277,9 +277,9 @@ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - END OF TERMS AND CONDITIONS+ END OF TERMS AND CONDITIONS - How to Apply These Terms to Your New Programs+ How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it@@ -304,8 +304,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along- with this program; if not, write to the Free Software Foundation, Inc.,- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.+ with this program; if not, see <https://www.gnu.org/licenses/>. Also add information on how to contact you by electronic and paper mail. @@ -329,8 +328,8 @@ Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. - <signature of Ty Coon>, 1 April 1989- Ty Coon, President of Vice+ <signature of Moe Ghoul>, 1 April 1989+ Moe Ghoul, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may
fedora-krb.cabal view
@@ -1,5 +1,5 @@ name: fedora-krb-version: 0.1.0+version: 0.1.1 synopsis: Kerberos for Fedora packagers description: A small library wrapping fkinit for Fedora developers.@@ -7,7 +7,7 @@ license-file: LICENSE author: Jens Petersen <petersen@redhat.com> maintainer: Jens Petersen <petersen@redhat.com>-copyright: 2024-2025 Jens Petersen <petersen@redhat.com>+copyright: 2024-2026 Jens Petersen <petersen@redhat.com> category: Distribution homepage: https://github.com/juhp/fedora-krb bug-reports: https://github.com/juhp/fedora-krb/issues@@ -17,7 +17,7 @@ cabal-version: 2.0 tested-with: GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.4, GHC == 8.10.7 GHC == 9.0.2, GHC == 9.2.8, GHC == 9.4.8, GHC == 9.6.6,- GHC == 9.8.4, GHC == 9.10.1+ GHC == 9.8.4, GHC == 9.10.3, GHC == 9.12.4 source-repository head type: git@@ -25,7 +25,10 @@ library build-depends: base < 5,- simple-cmd+ extra,+ simple-cmd,+ simple-prompt,+ unix default-language: Haskell2010 exposed-modules: Fedora.Krb hs-source-dirs: src
src/Fedora/Krb.hs view
@@ -5,16 +5,21 @@ ) where -import Control.Monad-import qualified Data.List as L-import Data.Maybe-import SimpleCmd+import Control.Monad (unless, when)+import Data.List.Extra (dropSuffix, find, isInfixOf, isSuffixOf)+import Data.Maybe (fromMaybe)+import SimpleCmd (cmdBool, cmdMaybe, error', (+-+))+import SimplePrompt (prompt)+import System.Posix.User (getLoginName) +-- | ensure there is a valid Fedora developer Kerberos ticket krbTicket :: IO () krbTicket = do entry <- klistEntryFedora if null entry- then error' "No krb5 ticket found for FEDORAPROJECT.ORG"+ then do+ putStrLn "No krb5 ticket found for FEDORAPROJECT.ORG"+ fkinit Nothing else when (last entry == "(Expired)") $ do putStrLn $ unwords entry@@ -22,18 +27,26 @@ putStrLn "" where fkinit muser = do- let opts = maybe [] (\user -> ["-u", user]) muser+ user <-+ case muser of+ Just u -> return u+ Nothing -> do+ username <- getLoginName+ inp <- prompt $ "Enter FAS username [default" +-+ username ++ "]"+ return $ if null inp then username else inp -- FIXME test for fkinit- ok <- cmdBool "fkinit" opts+ ok <- cmdBool "fkinit" ["-u", user] unless ok $ fkinit muser extractFasId :: [String] -> Maybe String extractFasId =- fmap (removeSuffix "@FEDORAPROJECT.ORG") . L.find ("@FEDORAPROJECT.ORG" `L.isSuffixOf`)+ fmap (dropSuffix "@FEDORAPROJECT.ORG") . find ("@FEDORAPROJECT.ORG" `isSuffixOf`) +-- | get FAS id from Krb ticket principal maybeFasIdFromKrb :: IO (Maybe String) maybeFasIdFromKrb = extractFasId <$> klistEntryFedora +-- | get FAS id from krb: error if no fedora ticket found fasIdFromKrb :: IO String fasIdFromKrb = do mfasid <- maybeFasIdFromKrb@@ -48,5 +61,5 @@ mres <- cmdMaybe "klist" ["-l"] return $ maybe []- (words . fromMaybe "" . L.find ("@FEDORAPROJECT.ORG" `L.isInfixOf`) . lines)+ (words . fromMaybe "" . find ("@FEDORAPROJECT.ORG" `isInfixOf`) . lines) mres