sessions.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:fluffy 作者: m4ce 项目源码 文件源码
def _load(self, rules):
        """Load IPTables rules

        Args:
            list: IPTables rules

        Returns:
            (int, Optional[str]): A tuple where the first object is the return code and the second is an optional error string associated to the return code.

        """

        tmpfile = tempfile.NamedTemporaryFile(
            dir=self._sessions_dir, delete=False)
        tmpfile.write("\n".join(rules))
        tmpfile.close()
        os.chmod(tmpfile.name, 0755)
        proc = subprocess.Popen(tmpfile.name, shell=True,
                                stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        out, err = proc.communicate()
        os.remove(tmpfile.name)

        return proc.returncode, err
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号