diff options
author | Dante Catalfamo | 2021-07-04 12:18:11 -0400 |
---|---|---|
committer | Dante Catalfamo | 2021-07-04 12:18:11 -0400 |
commit | 830655bb4a9cc719e4297de908f7cd043617cb40 (patch) | |
tree | 54ddbe114c8f4772b110fd5683bff9dd66417152 | |
parent | cb2fc1e5a402496dc1d650e2c4fbe69a3f6394e7 (diff) | |
download | blog-830655bb4a9cc719e4297de908f7cd043617cb40.tar.gz blog-830655bb4a9cc719e4297de908f7cd043617cb40.tar.bz2 blog-830655bb4a9cc719e4297de908f7cd043617cb40.zip |
bsd-auth: improve function lookup
-rwxr-xr-x | content/posts/WIP-how-bsd-authentication-works/gen_dot.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/content/posts/WIP-how-bsd-authentication-works/gen_dot.rb b/content/posts/WIP-how-bsd-authentication-works/gen_dot.rb index 5adb453..9f71876 100755 --- a/content/posts/WIP-how-bsd-authentication-works/gen_dot.rb +++ b/content/posts/WIP-how-bsd-authentication-works/gen_dot.rb @@ -1,10 +1,11 @@ #!/usr/bin/env ruby # frozen_string_literal: true -# Copyright (c) 2021 Dante Catalfamo +# Copyright (C) 2021 Dante Catalfamo # SPDX-License-Identifier: MIT require 'digest' +require 'set' SOURCE_DIR = File.join Dir.home, 'src', 'github.com', 'openbsd', 'src', 'lib', 'libc', 'gen' FILENAMES = %w[authenticate.c auth_subr.c login_cap.c].freeze @@ -42,7 +43,7 @@ class FunctionDigraph end def emit - puts "#{from} -> #{to} [color = \"##{color}\"]" if to =~ /auth|login|^_/ + puts "#{from} -> #{to} [color = \"##{color}\"]" end def color @@ -60,8 +61,12 @@ class FunctionDigraph puts 'rankdir=LR' puts 'splines=ortho' puts 'graph [pad="0.5", nodesep="0.5", ranksep="1.5"]' + all_functions = Set.new + @subgraphs.each { |s| all_functions.merge(s.functions) } @subgraphs.each(&:emit) - @pairs.uniq { |p| [p.to, p.from] }.each(&:emit) + @pairs.uniq { |p| [p.to, p.from] }.each do |p| + p.emit if all_functions.include?(p.to) + end puts '}' end |