<menu id="guoca"></menu>
<nav id="guoca"></nav><xmp id="guoca">
  • <xmp id="guoca">
  • <nav id="guoca"><code id="guoca"></code></nav>
  • <nav id="guoca"><code id="guoca"></code></nav>

    certbot.compat.filesystem module

    certbot.compat.filesystem模塊

    兼容模塊可在Windows和Linux上處理文件安全性

    certbot.compat.filesystem.chmod(file_path, mode)[source]
    在給定的file_path上應用POSIX模式:

    • 對于Linux,將使用chmod直接應用POSIX模式,
    • 對于Windows,POSIX模式將轉換為對Certbot上下文有意義的Windows DACL,并使用內核調用將其應用于文件。
      在Certbot的上下文中,對應于POSIX模式的Windows DACL的定義在https://github.com/certbot/certbot/issues/6356 中進行了說明,并由方法實現_generate_windows_flags()

    Parameters:

    • file_path (str) – Path of the file
    • mode (int) – POSIX mode to apply

    certbot.compat.filesystem.umask(mask)[source]
    設置當前的數字umask并返回上一個umask。在Linux上,使用內置的umask方法。在Windows上,使用我們的Certbot端實現。
    Parameters:
    mask (int) – The user file-creation mode mask to apply.
    Return type: int
    Returns: The previous umask value.


    certbot.compat.filesystem.``copy_ownership_and_apply_mode(src, dst, mode, copy_user, copy_group)[source]
    將所有權(用戶和Linux上的可選組)從源復制到目標,然后以兼容的方式將給定模式應用于Linux和Windows。這將替換os.chown命令。

    • Parameters:
      • src (str) – Path of the source file
      • dst (str) – Path of the destination file
      • mode (int) – Permission mode to apply on the destination file
      • copy_user (bool) – Copy user if True
      • copy_group (bool) – Copy group if True on Linux (has no effect on Windows)

    certbot.compat.filesystem.``copy_ownership_and_mode(src, dst, copy_user=True, copy_group=True)[source]
    將所有權(在Linux上為用戶和可選的組)和模式/ DACL從源復制到目標。

    • Parameters:
      • src (str) – Path of the source file
      • dst (str) – Path of the destination file
      • copy_user (bool)– Copy user if True
      • copy_group (bool) – Copy group if True on Linux (has no effect on Windows)

    certbot.compat.filesystem.``check_mode(file_path, mode)[source]
    檢查給定的模式是否匹配給定文件的權限。在Linux上,將進行直接比較;在Windows上,將與安全模型進行比較。

    • Parameters:
      • file_path (str) – Path of the file
      • mode (int) – POSIX mode to test
      • Return type: bool
      • Returns: True if the POSIX mode matches the file permissions

    certbot.compat.filesystem.``check_owner(file_path)[source]
    檢查給定文件是否歸當前用戶所有。
    Parameters:file_path (str) – File path to checkReturn type: bool
    Returns: 如果給定文件歸當前用戶所有,則為True,否則為False。

    certbot.compat.filesystem.check_permissions(file_path, mode)[source]
    檢查給定的文件是否具有給定的模式,并由當前用戶擁有。
    Parameters:

    • file_path (str) – File path to check
    • mode (int) – POSIX mode to check
      Return type: bool
      Returns:如果文件具有正確的模式和所有者,則為True,否則為False.

    certbot.compat.filesystem.open(file_path, flags, mode=511)[source]
    原始os.open函數的包裝器,可確保在Windows上正確應用給定模式。
    Parameters:

    • file_path (str) – 打開的文件路徑
    • flags (int) – 在打開時應用于文件的標志
    • mode (int) – POSIX模式在打開時應用于文件,如果None
      Returns: 打開的文件的文件描述符
      Return type: int
      Raise: OSError(errno.EEXIST)(如果文件已存在并且已設置os.O_CREAT和os.O_EXCL);如果文件已存在并且是目錄,則在Windows上為OSError(errno.EACCES);并且已設置os.O_CREAT。

    certbot.compat.filesystem.makedirs(file_path, mode=511)[source]
    重寫原始的os.mkdir函數,以確保在Windows上正確應用給定模式。
    Parameters:

    • file_path (str) – 打開的文件路徑
    • mode (int) – POSIX模式在創建時應用于葉目錄,如果沒有,則應用Python默認值

    certbot.compat.filesystem.mkdir(file_path, mode=511)source
    重寫原始的os.mkdir函數,以確保在Windows上正確應用給定模式。
    Parameters:

    • file_path (str) -打開的文件路徑
    • mode (int) – POSIX模式在創建時應用于葉目錄,如果沒有,則應用Python默認值

    certbot.compat.filesystem.replace(src,dst )資源
    將文件重命名為目標路徑,并處理目標存在的情況。
    參數:

    • src(str)–當前文件路徑。
    • dst(str)–新文件路徑。

    certbot.compat.filesystem.realpath(file_path )資源
    找到給定路徑的真實路徑。此方法解析符號鏈接,包括遞歸符號鏈接,并且受到保護以防止創建無限循環的符號鏈接。
    Parameters: file_path (str) – The path to resolve
    Returns: 如果路徑是可執行文件,則為True
    Return type: str

    certbot.compat.filesystem.is_executable(path)source
    路徑是可執行文件嗎?
    Parameters: path (str) – 測試路徑
    Returns: 如果路徑是可執行文件,則為True
    Return type: bool

    certbot.compat.filesystem.has_world_permissions(path)source
    檢查每個人/每個世界是否都對給定其路徑的文件擁有任何權利(讀/寫/執行)。
    Parameters: path (str)) – 測試路徑
    Returns: 如果每個人/世界都有權訪問該文件,則為true
    Return type: bool

    certbot.compat.filesystem.compute_private_key_mode(old_key, base_mode)[source]
    給定先前的私鑰,計算POSIX模式以應用于私鑰。
    Parameters:

    • old_key (str) – path to the previous private key
    • base_mode (int) – the minimum modes to apply to a private key
      Returns: the POSIX mode to apply
      Return type: int

    certbot.compat.filesystem.has_same_ownership(path1, path2)source
    如果兩個文件在各自路徑下的所有權相同,則返回True。在Windows上,僅針對所有者檢查所有權,因為文件沒有組所有者。
    Parameters:

    • path1 (str) – 第一個文件的路徑
    • path2 (str) – 第二個文件的路徑
      Returns: 如果兩個文件擁有相同的所有權,則為True,否則為False
      Return type: bool

    certbot.compat.filesystem.has_min_permissions(path, min_mode)source
    檢查給定路徑的文件是否至少具有給定最小模式定義的權限。在Windows上,由于文件沒有組所有者,因此將忽略組權限。
    Parameters:

    • path (str) – 要檢查的文件的路徑
    • min_mode (int) –預期最小權限
      Returns: 如果文件符合最小權限期望,則為True,否則為False
      Return type: bool

    本文章首發在 網安wangan.com 網站上。

    上一篇 下一篇
    討論數量: 0
    只看當前版本


    暫無話題~
    亚洲 欧美 自拍 唯美 另类