@@ -386,12 +386,14 @@ hostCheckFreeStorage = do
386386haveSystemAmtPt :: Rpc Bool
387387haveSystemAmtPt = dbReadWithDefault False " system-amt-pt-active"
388388
389- -- Check if this is laptop by testing the chassis type string
390- isLaptop :: IO Bool
391- isLaptop =
392- do hi <- readHostInfo
393- let chassis = map toLower . strip $ hostChassisType hi
394- return (chassis == " laptop" || chassis == " notebook" || chassis == " portable" )
389+ -- Check if this is laptop by testing the chassis type string against list of
390+ -- known keywords.
391+ isLaptopStr :: String -> Bool
392+ isLaptopStr chassisTypeStr =
393+ let keywords = [ " laptop" , " notebook" , " portable" ]
394+ chassisStrs = lines $ strip $ map toLower chassisTypeStr
395+ in
396+ foldl (||) False $ map (`elem` keywords) chassisStrs
395397
396398-- Check if host contains PCI devices required to turn AMT on
397399isAMTCapable :: IO Bool
@@ -457,9 +459,7 @@ readHostInfo = do
457459 eth0Addr <- future $ maybe " " id <$> eth0Mac
458460 wifiAddr <- future $ maybe " " id <$> wlan0Mac
459461 amt_cap <- future $ isAMTCapable
460- chassisType <- getHostChassisType
461- let chassis = map toLower . strip $ chassisType
462- is_laptop = (chassis == " laptop" || chassis == " notebook" || chassis == " portable" )
462+ chassisType <- getHostChassisType
463463 force $ HostInfo <$>
464464 vendor
465465 <*> model
@@ -472,7 +472,7 @@ readHostInfo = do
472472 <*> wifiAddr
473473 <*> wifiModel
474474 <*> pure chassisType
475- <*> pure is_laptop
475+ <*> pure (isLaptopStr chassisType)
476476 <*> amt_cap
477477 where
478478 fetch s regex = case s `matchG` regex of [] -> " "
0 commit comments