<commit_before>// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
// vim: ts=8 sw=2 smarttab
/*
 * Ceph - scalable distributed file system
 *
 * Copyright (C) 2004-2009 <NAME> <<EMAIL>>
 *
 * This is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1, as published by the Free Software 
 * Foundation.  See file COPYING.
 * 
 */

#include <errno.h>
#include <map>

#include "config.h"
#include "include/str_list.h"

#include "Crypto.h"
#include "auth/KeyRing.h"

#define DOUT_SUBSYS auth
#undef dout_prefix
#define dout_prefix *_dout << dbeginl << "auth: "


using namespace std;

KeyRing g_keyring;

bool KeyRing::load(const char *filename_list)
{
  string k = filename_list;
  string filename;
  list<string> ls;
  get_str_list(k, ls);
  bufferlist bl;
  bool loaded = false;
  for (list<string>::iterator p = ls.begin(); p != ls.end(); p++) {
    // subst in home dir?
    size_t pos = p->find("~/");
    if (pos != string::npos) {
      const char *home = getenv("HOME");
      if (home)
	p->replace(pos, 1, getenv("HOME"));
      else break; //skip, we couldn't correct it
    }

    if (bl.read_file(p->c_str(), true) == 0) {
      loaded = true;
      filename = *p;
      break;
    }
  }
  if (!loaded) {
    dout(0) << "can't open key file(s) " << filename_list << dendl;
    return false;
  }

  bufferlist::iterator p = bl.begin();
  decode(p);

  dout(1) << "loaded key file " << filename << dendl;
  return true;
}

void KeyRing::print(ostream& out)
{
  for (map<EntityName, EntityAuth>::iterator p = keys.begin();
       p != keys.end();
       ++p) {
    out << p->first << std::endl;
    out << "\tauid: " << p->second.auid << std::endl;
    out << "\tkey: " << p->second.key << std::endl;

    for (map<string, bufferlist>::iterator q = p->second.caps.begin();
	 q != p->second.caps.end();<commit_msg>auth: shut up about loading the key file<commit_after>// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
// vim: ts=8 sw=2 smarttab
/*
 * Ceph - scalable distributed file system
 *
 * Copyright (C) 2004-2009 <NAME> <<EMAIL>>
 *
 * This is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1, as published by the Free Software 
 * Foundation.  See file COPYING.
 * 
 */

#include <errno.h>
#include <map>

#include "config.h"
#include "include/str_list.h"

#include "Crypto.h"
#include "auth/KeyRing.h"

#define DOUT_SUBSYS auth
#undef dout_prefix
#define dout_prefix *_dout << dbeginl << "auth: "


using namespace std;

KeyRing g_keyring;

bool KeyRing::load(const char *filename_list)
{
  string k = filename_list;
  string filename;
  list<string> ls;
  get_str_list(k, ls);
  bufferlist bl;
  bool loaded = false;
  for (list<string>::iterator p = ls.begin(); p != ls.end(); p++) {
    // subst in home dir?
    size_t pos = p->find("~/");
    if (pos != string::npos) {
      const char *home = getenv("HOME");
      if (home)
	p->replace(pos, 1, getenv("HOME"));
      else break; //skip, we couldn't correct it
    }

    if (bl.read_file(p->c_str(), true) == 0) {
      loaded = true;
      filename = *p;
      break;
    }
  }
  if (!loaded) {
    dout(0) << "can't open key file(s) " << filename_list << dendl;
    return false;
  }

  bufferlist::iterator p = bl.begin();
  decode(p);

  dout(2) << "loaded key file " << filename << dendl;
  return true;
}

void KeyRing::print(ostream& out)
{
  for (map<EntityName, EntityAuth>::iterator p = keys.begin();
       p != keys.end();
       ++p) {
    out << p->first << std::endl;
    out << "\tauid: " << p->second.auid << std::endl;
    out << "\tkey: " << p->second.key << std::endl;

    for (map<string, bufferlist>::iterator q = p->second.caps.begin();
	 q != p->second.caps.end();
{'fraction_non_alphanumeric': 0.17455391776570986, 'fraction_numerical': 0.009309542280837859, 'mean_word_length': 3.1061571125265393, 'pattern_counts': {'":': 0, '<': 85, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4892987', 'n_tokens_mistral': 1425, 'n_tokens_neox': 1366, 'n_words': 388}