Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 453 user and password must be encoded #472

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified MANIFEST.SKIP
100755 → 100644
Empty file.
Empty file modified META.yml
100755 → 100644
Empty file.
Empty file modified Makefile.PL
100755 → 100644
Empty file.
Empty file modified etc/init.d/ocsinventory-agent
100755 → 100644
Empty file.
Empty file modified etc/ocsinventory-agent/softwares/example.sh
100755 → 100644
Empty file.
17 changes: 17 additions & 0 deletions lib/Ocsinventory/Agent/Backend/OS/Generic/Batteries/SysClass.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package Ocsinventory::Agent::Backend::OS::Generic::Batteries::SysClass;

use strict;
use warnings;

use vars qw($runAfter);
$runAfter = ["Ocsinventory::Agent::Backend::OS::Generic::Dmidecode::Batteries"];

sub run {
my $params = shift;
my $common = $params->{common};



}

1;
88 changes: 88 additions & 0 deletions lib/Ocsinventory/Agent/Backend/OS/Generic/Batteries/Upower.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package Ocsinventory::Agent::Backend::OS::Generic::Batteries::Upower;

use strict;
use warnings;
use Data::Dumper;
use English qw( -no_match_vars ) ;
use vars qw($runAfter);
$runAfter = [ "Ocsinventory::Agent::Backend::OS::Generic::Dmidecode::Batteries" ];

sub check {
my $params = shift;
my $common = $params->{common};

return unless $common->can_run("upower");
}

sub run {

my $params = shift;
my $common = $params->{common};

my $battery;

# Enumarate devices
my @batteriesName = _getBatteriesNameFromUpower();

#
return unless @batteriesName;

my @batteries = ();
foreach my $battname (@batteriesName) {
$battery = _getBatteryFromUpower($battname);
}

print Dumper($battery);

}

sub _getBatteriesNameFromUpower {

my @lines = `upower --enumerate`;

my @battname;
for my $line (@lines) {
if ($line =~ /^(.*\/battery_\S+)$/) {
push @battname, $1;
}
}

return @battname;
}

sub _getBatteryFromUpower {

my ($batname) = @_;

my @bat = `upower -i $batname`;

my $data = {};
foreach my $line (@bat) {
if ($line =~ /^\s*(\S+):\s*(\S+(?:\s+\S+)*)$/) {
$data->{$1}=$2;
}
}

my $battery = {
NAME => $data->{'model'},
CHEMISTRY => $data->{'technology'},
SERIAL => $data->{'serial'},
};

my $manufacturer = $data->{'vendor'} || $data->{'manufacturer'};
#$battery->{MANUFACTURER} = getCanonicalManufacturer($manufacturer) if $manufacturer;

my $voltage = $data->{'voltage'};
$battery->{VOLTAGE} = $voltage if $voltage;

my $capacity = $data->{'energy-full-design'};
$battery->{CAPACITY} = $capacity if $capacity;

my $real_capacity = $data->{'energy-full'};
$battery->{REAL_CAPACITY} = $real_capacity if defined($real_capacity) && length($real_capacity);

return $battery;

}

1;
4 changes: 2 additions & 2 deletions lib/Ocsinventory/Agent/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@ sub help {
print STDERR "\t--lazy do not contact the server more than one time during the PROLOG_FREQ (".$self->{config}{lazy}.")\n";
print STDERR "\t-l --local=DIR do not contact server but write inventory in DIR directory in XML (".$self->{config}{local}.")\n";
print STDERR "\t --logfile=FILE log message in FILE (".$self->{config}{logfile}.")\n";
print STDERR "\t-p --password=PWD password for server auth\n";
print STDERR "\t-p --password=PWD password for server auth. Password must be encoded in base64.\n";
print STDERR "\t-P --proxy=PROXY proxy address. e.g: http://user:pass\@proxy:port (".$self->{config}{proxy}.")\n";
print STDERR "\t-r --realm=REALM realm for server auth. e.g: 'Restricted Area' (".$self->{config}{realm}.")\n";
print STDERR "\t-s --server=uri server uri (".$self->{config}{server}.")\n";
print STDERR "\t --stdout do not write or post the inventory but print it on STDOUT\n";
print STDERR "\t-t --tag=TAG use TAG as tag (".$self->{config}{tag}."). Will be ignored by server if a value already exists.\n";
print STDERR "\t-u --user=USER user for server auth (".$self->{config}{user}.")\n";
print STDERR "\t-u --user=USER user for server auth (".$self->{config}{user}."). USER must be encoded in base64\n";
print STDERR "\t --version print the version\n";
print STDERR "\t-w --wait=seconds wait a random period before contacting server like --daemon does (".$self->{config}{wait}.")\n";
# print STDERR "\t-x --xml write output in a xml file ($self->{config}{xml})\n";
Expand Down
Empty file.
Empty file.
Empty file.
Empty file modified macosx/ocsinventory_packages_setup/logos/OCS_logo.jpg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified macosx/ocsinventory_packages_setup/scripts/postinstall
100755 → 100644
Empty file.
Empty file modified macosx/ocsinventory_packages_setup/scripts/preinstall
100755 → 100644
Empty file.
Empty file modified macosx/ocsng_app-xcode/GetPID.c
100755 → 100644
Empty file.
Empty file modified macosx/ocsng_app-xcode/GetPID.h
100755 → 100644
Empty file.
Empty file modified macosx/scripts/create-darwin-perl-lib_fromCPAN.pl
100755 → 100644
Empty file.
Empty file modified macosx/scripts/uninstaller.sh
100755 → 100644
Empty file.
Empty file modified memconf
100755 → 100644
Empty file.
Empty file modified ocsinventory-agent
100755 → 100644
Empty file.
Empty file modified postinst.pl
100755 → 100644
Empty file.
Empty file modified tools/build-perl-tree.sh
100755 → 100644
Empty file.
Empty file modified tools/encryptText.pm
100755 → 100644
Empty file.
Empty file modified tools/makedist.sh
100755 → 100644
Empty file.
Empty file modified tools/standalone.sh
100755 → 100644
Empty file.